はルビー2.3.0にhas_many関係の暗黙的な変換エラーにとレールバージョン
と
レールに
ルビー1.9.3-P551を投写します3.2.13〜レール3.2.22(3-2-stable)
アップグレード前にエラーはありませんでした。
ユーザの連絡先を管理するために私はいくつかの複雑な関係を持っていますが、これらの関係にアクセスすると、の文字列に暗黙的にnilが変換されていませんエラー。
関係は次のように定義されている -
レールC私は実行することにより、完全なスタックトレースを取得することができています使用has_many :contacts, :foreign_key => 'owner_id'
has_many :pending_invited, conditions: {:'contacts.confirmed' => false, :'contacts.denied' => false }, through: :contacts, class_name: 'User', source: :user
has_many :invited, conditions: { :'contacts.confirmed' => true }, through: :contacts, class_name: 'User', source: :user
has_many :inverse_contacts, :foreign_key => 'user_id', :class_name => 'Contact'
has_many :pending_invited_by, conditions: {:'contacts.confirmed' => false, :'contacts.denied' => false }, through: :inverse_contacts, class_name: 'User', source: :owner
has_many :invited_by, conditions: {:'contacts.confirmed' => true }, through: :inverse_contacts, class_name: 'User', source: :owner
has_many :denied, conditions: {:'contacts.denied' => true }, through: :contacts, class_name: 'User', source: :user
has_many :denied_by, conditions: {:'contacts.denied' => true }, through: :inverse_contacts, class_name: 'User', source: :owner
-
u = User.first
u.pending_invited_by
をし、これが次のエラーを生成します -
をTypeError: no implicit conversion of nil into String
from .bundle/gems/arel-3.0.3/lib/arel.rb:40:in `initialize'
from .bundle/gems/arel-3.0.3/lib/arel.rb:40:in `new'
from .bundle/gems/arel-3.0.3/lib/arel.rb:40:in `sql'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/join_helper.rb:47:in `block in sanitize'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/join_helper.rb:45:in `map'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/join_helper.rb:45:in `sanitize'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/association_scope.rb:94:in `block in add_constraints'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/association_scope.rb:39:in `each'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/association_scope.rb:39:in `each_with_index'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/association_scope.rb:39:in `add_constraints'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/association_scope.rb:31:in `scope'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/association.rb:99:in `association_scope'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/association.rb:88:in `scoped'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/has_many_through_association.rb:178:in `find_target'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/collection_association.rb:335:in `load_target'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/collection_proxy.rb:44:in `load_target'
from .bundle/bundler/gems/rails-f85bbed4cdc1/activerecord/lib/active_record/associations/collection_proxy.rb:89:in `method_missing'
from .bundle/bundler/gems/rails-f85bbed4cdc1/railties/lib/rails/commands/console.rb:47:in `start'
from .bundle/bundler/gems/rails-f85bbed4cdc1/railties/lib/rails/commands/console.rb:8:in `start'
from .bundle/bundler/gems/rails-f85bbed4cdc1/railties/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
何か助けていただければ幸いです。
実行宝石の更新--systemをします修正する – Boltz0r