我有模型配置文件而不是用户,当我试图这样做时:
<% if can? :update, @article %>
<%= link_to "Edit", edit_article_path(@article) %> |
<% end %>
我收到了错误: 未定义的局部变量或方法`current_user'用于#
我也在使用命名空间Admin,所以我有http://localhost:3000/admin/profile等等。 你能告诉我如何更改默认设置吗?我试着说:
def current_ability
@current_user ||= Ability.new(current_profile)
end
在application_controller.rb中,但仍然无效。
答案 0 :(得分:0)
根据https://github.com/ryanb/cancan/wiki/Changing-Defaults,我认为应该是:
# in ApplicationController
def current_ability
@current_ability ||= Ability.new(current_profile)
end
需要将其称为 @current_ability 。