我正在尝试使用将操作链接添加到活动脚手架控制器
if current_user.can? :update, Post
config.action_links.add 'export', :label => 'Export', :page => true
end
但是无论我尝试使用什么控制器,我总是会得到undefined method current_user
所以,我如何检查登录的用户是否可以/不能做某事?
我什至尝试过
def ability
@ability ||= Ability.new(self)
end
delegate :can?, :cannot?, :to => :ability
正如这里所建议的那样,但没有成功。
这有什么问题?