Hi all!

I'm trying to do the following thing:

class Show < ActiveRecord::Base
  has_many :pools
  has_many :tickets, :through => :pools
end

class Pool < ActiveRecord::Base
  belongs_to :show
  has_many :tickets
end

class Ticket < ActiveRecord::Base
  belongs_to :pool
end

Now with an instance of Show, the following works correctly:
show.tickets

But when I create a new show, Rails wants to build tickets or do
something with it. An
ActiveRecord::HasManyThroughCantAssociateThroughHasManyReflection is
raised with the message "Cannot modify association 'Show#tickets'
because the source reflection class 'Ticket' is associated to 'Pool' via
:has_many."

I don't quite understand this, since the API docs tell me that:

:through
    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?

Thanks!

Wouter
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to