在我的ability.rb 文件中,如何设置它以便只有定义的用户可以做事,否则(未定义/未登录的用户)不能做任何事情?
例子:
def initialize(user)
user ||= User.new #not logged in user
if user.admin_user?
can :manage, :all
else
#can't do anything. Cannot view, edit, or update.
end
end
谢谢!