Rails, has_many :through, undefined method `to_sym` for nil:NilClass Rails, has_many :through, undefined method `to_sym` for nil:NilClass ruby-on-rails ruby-on-rails

Rails, has_many :through, undefined method `to_sym` for nil:NilClass


When you are calling .new on tournaments it does not have an id, so it will be nil. Therefore will not find the user.

Also when you are remapping a model in a has many through like this you have to tell active record what the model it is looking for is. You do this with the :source argument. Here is how tournament would work.

class Tournament < ActiveRecord::Base  has_many :participants_tournaments  has_many :participants, :through => :participants_tournaments, :source => :userend