I keep getting that error when trying to access any of my views. I'm trying to setup Declaritive Authorization.
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
role_symbols is calling role.map, but role isn't defined yet
精彩评论