2012-05-31 3 views
0

Получение следующее сообщение об ошибке при попытке intall рельсы администратора ... Предполагая, сво ошибка модели ассоциации, но я не могу понять его ..Модель ошибка ассоциации Rails Администратор

/Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/inheritance.rb:119:in `compute_type': uninitialized constant Interest::Person (NameError) 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/reflection.rb:172:in `klass' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/rails_admin/adapters/active_record.rb:218:in `association_model_lookup' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/rails_admin/adapters/active_record.rb:63:in `block (2 levels) in associations' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/rails_admin/config/fields/association.rb:59:in `call' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/rails_admin/config/fields/association.rb:59:in `associated_model_config' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/rails_admin/config/fields/association.rb:34:in `block in <class:Association>' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/rails_admin/config/configurable.rb:68:in `instance_eval' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/rails_admin/config/configurable.rb:68:in `block in register_instance_option' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/rails_admin/config/configurable.rb:42:in `block in register_instance_option' 
    from (erb):86:in `block (2 levels) in template' 
    from (erb):85:in `map' 
    from (erb):85:in `block in template' 
    from (erb):82:in `map' 
    from (erb):82:in `template' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `eval' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `result' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:111:in `block in template' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in `call' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in `render' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/create_file.rb:47:in `identical?' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/create_file.rb:73:in `on_conflict_behavior' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:111:in `invoke_with_conflict_check' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/create_file.rb:61:in `invoke!' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions.rb:95:in `action' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/create_file.rb:26:in `create_file' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:110:in `template' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rails_admin-0.0.3/lib/generators/rails_admin/install_generator.rb:62:in `install' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/generators.rb:170:in `invoke' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/generate.rb:12:in `<top (required)>' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' 
    from /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:29:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

Модели

class User < ActiveRecord::Base 
    has_many :friends 
    has_many :person_interests, :as => :person 
    has_many :interests, :through => :person_interests 
    has_many :user_holidays 
    has_many :holidays, :through => :user_holidays 
    has_many :anniversaries 
end 

class PersonInterest < ActiveRecord::Base 
    attr_accessible :person_id, :person_type, :interest_ids 
    belongs_to :interest 
    belongs_to :person, :polymorphic => true 

end 

class Interest < ActiveRecord::Base 
    attr_accessible :name 
    has_many :person_interests 
    has_many :people, :through => :person_interests 

end 

ответ

4

Проблема в том, что ваша ассоциация has_many :people похожа на вашу модель Interest:

has_many :people, :through => :people_interest 

Ассоциация person внутри вашего PersonInterest модель наверняка достаточно polymorphic, но has_many :through не уважает это.

Поэтому я бы рекомендовал попытаться найти другой способ получить всех людей. Вы можете сделать этот хакерский путь:

def people 
    person_interests.includes(:person).map(&:people).flatten.uniq 
end 
+0

'person_interests.includes (: person) .map (&: people) .flatten.uniq' – davidcelis

Смежные вопросы