Forum: Ruby on Rails has_many / : through / check_box - update problems

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Terry Shuttleworth (Guest)
on 2006-06-09 20:32
(Received via mailing list)
Can anyone help me with this, which has been making me tear my hair out
for 2
days now ?

I have the following classes using has_many :through relationships...
(I've changed the class names to make it easier to understand, so don't
beat me up about naming conventions ;) )

class Movie < ActiveRecord::Base
	has_many :localdetails
	has_many :territories, :through=>:rights

class Territory < ActiveRecord::Base
	has_many :localdetails
	has_many :movies, :through=>:rights

class LocalDetail < ActiveRecord::Base
	belongs_to :movie
	belongs_to :territory

The tables contain the usual *_id fields, and all display correctly,
so no need to worry there.
Localdetails contains extra info, including a "will_be_shown_here" field

I've got code that makes sure that for every Movie-Territory pair, there
is a record in the localdetails table

While in a Movies controller, I want to loop through each Territory and
display a line which allows editing of the localdetails for that Movie
for each Territory, something like...

for territory in @territories
  localdetail=LocalDetail.find(:all, :conditions['territory_id=? AND


But I can't find any form of syntax for the checkbox that will allow
this to work.

I think I've tried everything, but of course, you may know better...

Any ideas ?
This topic is locked and can not be replied to.