2010-11-24 14 views
2

Ich laufe RVM (Ruby 1.8.7-Kopf, Rails 2.3.8) und habe die BASICS einer neuen App laufen. Ich arbeite mit Authlogic, mit dem minimalen Code, um das zu machen. Ich versuche, ACL9 zu verwenden (was ich habe auf einem anderen Projekt arbeiten, gleiche RVM gemset)ACL9 und Rails 2.3.8 - NameError: nicht initialisierte Konstante Benutzer :: Rolle

class User < ActiveRecord::Base 
    # authentication 
    acts_as_authentic 

    # authorization 
    acts_as_authorization_subject 

    def full_name 
    "#{self.first_name} #{self.last_name}" 
    end 
end 

Wenn ich versuche, nur eine einfache Prüfung durchführen, um sicherzustellen, ACL9 richtig ... arbeitet

script/console

u = User.first

u.has_role?(:anyrole)

ich diesen Fehler ...

ruby-1.8.7-head > u.has_role?(:anyrole) 
NameError: uninitialized constant User::Role 
    from /Users/development/.rvm/gems/[email protected]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in `const_missing' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/base.rb:1:in `compute_type' 
    from /Users/development/.rvm/gems/[email protected]/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/base.rb:2230:in `compute_type' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/reflection.rb:156:in `send' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/reflection.rb:156:in `klass' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/reflection.rb:187:in `quoted_table_name' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/associations/has_and_belongs_to_many_association.rb:102:in `construct_sql' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:21:in `initialize' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/associations/has_and_belongs_to_many_association.rb:5:in `initialize' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/associations.rb:1306:in `new' 
    from /Users/development/.rvm/gems/[email protected]/gems/activerecord-2.3.8/lib/active_record/associations.rb:1306:in `role_objects' 
    from /Users/development/.rvm/gems/[email protected]/gems/acl9-0.12.0/lib/acl9/model_extensions/for_subject.rb:39:in `has_role?' 
    from (irb):2 

ich bin mir nicht sicher, warum dies mit jedem anderen App funktioniert ich habe, aber nicht diese - und ich bin nicht sicher, was die Fehlermeldung sagt. Jede Hilfe wird geschätzt.

Antwort

2
class Role < ActiveRecord::Base 
    acts_as_authorization_role 
    end 
Verwandte Themen