2010-11-28 49 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

相關問題