2010-11-28 94 views
0

我试图访问我的任何视图时不断收到该错误。我正在尝试设置Declaritive授权。未定义的局部变量或方法`角色'用户:

class User < ActiveRecord::Base 

    acts_as_authentic do |c| 
    c.login_field = :username 
    end 

    ROLES = %w[admin moderator subscriber] 

    has_and_belongs_to_many :channels 
    has_many :channel_mods 
    named_scope :with_role, lambda { |role| {:conditions => "roles_mask & #{2**ROLES.index(role.to_s)} > 0 "} } 

    def role_symbols 
    role.map do |role| 
     role.name.underscore.to_sym 
    end 
    end 

    def roles=(roles) 
    self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum 
    end 

    def roles 
    ROLES.reject { |r| ((roles_mask || 0) & 2**ROLES.index(r)).zero? } 
    end 

end 

回答

1

role_symbols呼吁role.map,但作用还没有定义

+0

谢谢,我还以为你可以定义的东西坏了红宝石关系吗? – 2010-11-28 02:24:29

相关问题