0

インストーラーを実行すると、次のように表示されます。出力は奇妙で、外部キーとリフレクションに関する不満があります。source_reflection は nil ですか? 修正に関するアイデアはありますか?

また、このフォームに記入するために追加のドリブルを追加しない限り、この質問を投稿させないので、SOは本当に面倒です. さあ、そう!!!

 -  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>'
4

1 に答える 1

0

このエラーを解決するのにしばらく時間がかかりました。別のSOの回答と外部の支援により、エラーの原因についての手がかりが得られました。その SO はここにあり、ポリモーフィックな関連付けによる反射エラーです

私を助けたもう1つのSOは、管理者に提示するためにすべての関係を知る必要があるため、レール、またはこの場合はレール管理者の関連付けをより明確にする方法を理解することでした. :レールのソースオプション

問題は、ソースのレールにあまり明確ではないポリモーフィックな関連付けがあったことです。Rails管理者の混乱の原因を取り除くと、エラーなしで続行できました.

2 つの注意事項:

  1. すでにdeviseでadminクラスを作成している場合は、rails adminによって自動生成されたマイグレーションファイルを編集または削除する必要があります。これは AddDeviseToAdmins と呼ばれます。現在の管理テーブルに既にあるフィールドと重複しないように、必ず編集してください。私の場合、デフォルトのデバイスで生成された管理テーブルにはすでにすべてが含まれていたため、ファイルを完全に削除しました。

  2. 最初の SO には :source-type => "something" という 2 番目のオプションがあり、タイプミスです。:source_type => "something" である必要があります。ダッシュではなくアンダースコアを使用します。

于 2013-11-15T21:12:33.640 に答える