正如我在标题中所写,我不知道如何向用户添加角色。
我做了这样的事Compilers are allowed to declare C functions such as abs
in the global namespace in addition to namespace std
我的session_controller.rb
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.role?(:admin)
can :manage, :all
else
can :read, :all
end
end
end
我的能力.rb
ROLES = {0 => :guest, 1 => :admin}
attr_reader :role
def initialize(role_id = 0)
@role = ROLES.has_key?(role_id) ? ROLES[role_id] : ROLES[0]
end
def role?(role_name)
role == role_name
end
这是我的user.rb模型
var eleDOM = document.getElementById('list');
现在,我可以在tutorial
上执行此操作