I’m trying to do the following thing:
class Show < ActiveRecord::Base
has_many :tickets, :through => :pools
class Pool < ActiveRecord::Base
class Ticket < ActiveRecord::Base
Now with an instance of Show, the following works correctly:
But when I create a new show, Rails wants to build tickets or do
something with it. An
raised with the message “Cannot modify association ‘Show#tickets’
because the source reflection class ‘Ticket’ is associated to ‘Pool’ via
I don’t quite understand this, since the API docs tell me that:
Specifies a Join Model through which to perform the query. Options
for :class_name and :foreign_key are ignored, as the association uses
the source reflection. You can only use a :through query through a
belongs_to or has_many association on the join model.
At the top of the backtrace I see that Rails is trying to insert a
record for the association. Why?
Is there a way to work around this?