Question

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
Was it helpful?

Solution

role_symbols is calling role.map, but role isn't defined yet

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top