这是我运行安装程序时显示的内容。关于外键和反思的一些抱怨,输出很奇怪。 source_reflection是零?有任何关于修复的想法吗?
另外,S.O。真的很烦人,不要让我发布这个问题,除非我添加一堆额外的运球来填写这个表格。来吧S.O !!!
- Hello, RailsAdmin installer will help you set things up!
- I need to work with Devise, let's look at a few things first:
- Checking for a current installation of devise...
- Found it!
- Looks like you've already installed it, good!
? Where do you want to mount rails_admin? Press <enter> for [admin] >
gsub config/routes.rb
route mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
- And you already set it up, good! We just need to know about your user model name...
- We found 'user' (should be one of 'user', 'admin', etc.)
? Correct Devise model name if needed. Press <enter> for [user] > admin
- Now setting up devise with user model name 'admin':
generate devise
invoke active_record
create db/migrate/20131114155103_add_devise_to_admins.rb
insert app/models/admin.rb
route devise_for :admins
- Now you'll need an initializer...
create config/initializers/rails_admin.rb
/Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/activerecord-4.0.0/lib/active_record/reflection.rb:401:in `rescue in foreign_key': ActiveRecord::Reflection::ThroughReflection#foreign_key delegated to source_reflection.foreign_key, but source_reflection is nil: #<ActiveRecord::Reflection::ThroughReflection:0x007f87de0c5bd0 @macro=:has_many, @name=:transactions, @scope=nil, @options={:through=>:locatables}, @active_record=Address(id: integer, street: string, city: string, state: string, zip: string, country: string, created_at: datetime, updated_at: datetime, latitude: float, longitude: float), @plural_name="transactions", @collection=true, @source_reflection_names=[:transaction, :transactions], @through_reflection=#<ActiveRecord::Reflection::AssociationReflection:0x007f87dafbb670 @macro=:has_many, @name=:locatables, @scope=nil, @options={}, @active_record=Address(id: integer, street: string, city: string, state: string, zip: string, country: string, created_at: datetime, updated_at: datetime, latitude: float, longitude: float), @plural_name="locatables", @collection=true, @foreign_key="address_id", @class_name="Locatable", @klass=Locatable(id: integer, owner_id: integer, owner_type: string, address_id: integer, created_at: datetime, updated_at: datetime, pickup: boolean, kind: string)>, @source_reflection=nil> (RuntimeError)
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/activerecord-4.0.0/lib/active_record/reflection.rb:397:in `foreign_key'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/adapters/active_record.rb:306:in `association_foreign_key_lookup'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/adapters/active_record.rb:72:in `block in associations'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/adapters/active_record.rb:65:in `map'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/adapters/active_record.rb:65:in `associations'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/fields/factories/association.rb:6:in `block in <top (required)>'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/fields.rb:54:in `call'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/fields.rb:54:in `block (2 levels) in factory'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/fields.rb:54:in `each'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/fields.rb:54:in `find'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/fields.rb:54:in `block in factory'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/fields.rb:50:in `each'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/fields.rb:50:in `factory'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/has_fields.rb:130:in `_fields'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/has_fields.rb:128:in `_fields'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/has_fields.rb:108:in `all_fields'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/rails_admin/config/has_fields.rb:83:in `fields'
from (erb):64:in `block in template'
from (erb):53:in `map'
from (erb):53:in `template'
from /Users/JCC/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/erb.rb:849:in `eval'
from /Users/JCC/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/erb.rb:849:in `result'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/file_manipulation.rb:117:in `block in template'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/create_file.rb:54:in `call'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/create_file.rb:54:in `render'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/create_file.rb:63:in `block (2 levels) in invoke!'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/create_file.rb:63:in `open'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/create_file.rb:63:in `block in invoke!'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/empty_directory.rb:117:in `call'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/empty_directory.rb:117:in `invoke_with_conflict_check'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/create_file.rb:61:in `invoke!'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions.rb:95:in `action'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/create_file.rb:26:in `create_file'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/actions/file_manipulation.rb:116:in `template'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/rails_admin-0.5.0/lib/generators/rails_admin/install_generator.rb:75:in `install'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `block in invoke_all'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `each'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `map'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `invoke_all'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/group.rb:233:in `dispatch'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/railties-4.0.0/lib/rails/generators.rb:156:in `invoke'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/railties-4.0.0/lib/rails/commands/generate.rb:11:in `<top (required)>'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/JCC/.rvm/gems/ruby-2.0.0-p247@testing/gems/railties-4.0.0/lib/rails/commands.rb:49:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
答案 0 :(得分:0)
这个错误让我花了一些时间来消磨。另一个SO答案以及一些外部协助给了我关于什么是错误的线索。那里的SO reflection error with polymorphic association
帮助我的其他SO是了解你需要如何使关联更清晰的rails,或者在这种情况下,rails admin,因为它需要知道所有的关系,以便将它呈现给管理员。 :source options in rails
问题是我有一个多态关联,对于源代码的轨道来说并不是很清楚。一旦我删除了rails admin的混乱源,我就可以继续没有错误。
两项注意事项:
如果您已经使用devise创建了一个管理类,则必须编辑或删除由rails admin自动生成的迁移文件。它叫做AddDeviseToAdmins。确保对其进行编辑,使其不会复制当前管理表中已有的字段。在我的情况下,我完全删除了文件,因为我的默认设计生成的管理表已经包含了所有内容。
第一个S.O.有第二个选项:source-type =&gt; “某事”,这是错误的。它应该是:source_type =&gt; “东西”。使用下划线而不是破折号。