简单的 CanCan 问题
我刚刚开始使用 CanCan,这里是代码示例:
# Ability.rb
def initialize(user)
user ||= User.new
can :read, Link
end
# view.html.erb
<% if can? :read, @link %>
...
<% end %>
这是来自 CanCan 的 github 存储库,但这似乎不起作用(它返回 false 并阻止 ...
代码运行)。
当我将视图更改为 <% 时可以吗? :阅读,链接%>
,它有效。但是,这与 CanCan 自述文件不同。你知道我哪里错了吗?
I have just started with CanCan and here's a sample of the code:
# Ability.rb
def initialize(user)
user ||= User.new
can :read, Link
end
# view.html.erb
<% if can? :read, @link %>
...
<% end %>
This is from the github repo for CanCan but this doesn't seem to work (it returns false and stops the ...
code from running).
When I change the view to <% if can? :read, Link %>
, it works. But, this is different to the CanCan readme. Do you know where I'm going wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查
Check that
是链接的概念...类似于“你能阅读所有链接吗?”
这会检查以确保您可以读取有问题的特定链接对象
is the concept of a link... something to the akin of "Can you read all links?"
This checks to make sure you can read the specific link object in question