> On 23 Apr, 09:03, johnnybutler7 <[email protected]> wrote:
>> Hi,
>>
>> Hasanyone managed to gethasmanythroughrelationships to update and
>> save?  I can get them to display on the forms but they never update or
>> save.  My models\controllers are below.  So basically if i try to edit
>> \create a product i get a check box list of the different operating
>> systems Mac, PC, Linux etc that i can tick but they never save.  Ive
>> tried some changes like changing operating_systems to
>> product_operating_systems but it didnt work.  I know it will work with
>> HABTM but i dont want to go down this route as its all setup to work
>> withhasmanythrough.
>>
>> class Product < ActiveRecord::Base
>>   has_many :product_operating_systems
>>   has_many :operating_systems, :through=> :product_operating_systems
>> end
>>
>> class OperatingSystem < ActiveRecord::Base
>>   has_many :product_operating_systems
>>   has_many :products, :through=> :product_operating_systems
>> end
>>
>> class ProductOperatingSystem < ActiveRecord::Base
>>   belongs_to :product
>>   belongs_to :operating_system
>> end
>>
>> class Admin::ProductsController < ApplicationController
>>   active_scaffold :product do |config|
>>     config.columns = [:operating_systems]
>>    columns[:operating_systems].form_ui = :select
>>   end
>> end
>>
>> If anyone can help it would be appreciated as i have quite a
>> fewhasmanythroughto use with AS.
>>
>> Im on rails 2.3.3 and the latest version of AS,
>>
>> JB

When you use has_many :through, to create or edit you must use the has_many
association. has_many :through is used when relating model
(ProductOperatingSystem in your case) has other attributes, so you must
create a ProductOperatingSystem to fill that attributes, you can't
associate a Product with an Operating System directly.

When create/edit a product, you should create ProductOperatingSystem lines
to fill some attributes and select an OperatingSystem.

> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to