thanks for responding Frederick:  So just to clarify you mean:

(a) I would have to do this in my controller in the "save" method right?
(b) so anyone that anyone using Rails that has nested models in their
views do have to do this too then?  i.e. extract work in the
controller?  i.e. there's no ability in Rails 2.1 with nested models
to have the params perfectly auto-populated the models (i.e. parent
model and it's association models) out-of-the-box?

thanks again



On Sun, Nov 23, 2008 at 1:00 AM, Frederick Cheung
<[EMAIL PROTECTED]> wrote:
>
>
>
> On Nov 22, 11:56 am, "Greg Hauptmann" <[EMAIL PROTECTED]>
> wrote:
>> ok, re "I'm just trying to load a set of options which doesn't require
>> tables (i.e. using tableless plugin)" I've got the View working now,
>> however when I submit back I have an error as Rails tries to populate
>> the association models.   Any ideas - it's like the parameter
>> array/hash structure coming into Rails is fine, however when it tries
>> to load the association data into the model for the associations it
>> has a problem.
>>
>> Is my model (graph_options.rb) correct?   Do I need to specify a
>> specific "attr_accessible :lines" here?  Or should the "has_many
>> :lines" be enough?
>
> attr_accessible is something completely different. The issue here is
> that all update_attributes does is for each key value pair it calls
> your_model.send("#{key}=", value). That's fine for attributes, but
> that means that what it's passing to lines= is not an array of Line
> items, but an array of hashes.
> In rails 2.1 you just have to extract that array of hashes, turn it
> into objects of the right type and then assign it to
> your_object.lines. There was talk of changing this in rails 2.2 but I
> can't remember what was done about it in the end.
>
> Fred
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to