I have just upgraded my ruby on rails project
ruby 1.9.3-p551 to ruby 2.3.0
and
rails 3.2.13 to rails 3.2.22 (3-2-stable)
There were no errors prior to the upgrade.
In my user model I have some complex relationships in order to manage a user's contacts, and when accessing these relations I am getting a no implicit conversion of nil into String error.
The relationships are defined as -
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
Using rails c I am able to get a full stack trace by running -
u = User.first
u.pending_invited_by
and this produces the following error -
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'
Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire