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