2010-11-24 8 views
2

私はRVM(Ruby 1.8.7-head、Rails 2.3.8)を実行しており、新しいアプリケーションのBASICSを実行しています。 Authlogicは最小限のコードで作業しています。私はACL9とRails 2.3.8 - NameError:初期化されていない定数User :: Role

class User < ActiveRecord::Base 
    # authentication 
    acts_as_authentic 

    # authorization 
    acts_as_authorization_subject 

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

私はちょうどACL9が正常に動作していることを確認するために簡単なチェックを実行しようと...(私は別のプロジェクトに取り組んできた、同じRVMのgemset)ACL9を使用しようとしています

script/console

u = User.first

u.has_role?(:anyrole)

これは私が持っている他のすべてのアプリで動作しますが、ありませんこの1なぜ

私はこのエラーを取得...

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 

は私はわからない - と私は、エラーメッセージが言っているかわからないんだけど。何か助けていただければ幸いです。

答えて

2
class Role < ActiveRecord::Base 
    acts_as_authorization_role 
    end