I guess one of the use cases is a list of checkboxes, eg:

http://railscasts.com/episodes/165-edit-multiple

... but I think it holds for any list that would present multiple
non-nested objects for editing in a single form.

Ryan's implementation makes use of form_tag and a loop inside the
controller action ... which to me indicates a bit of code smell, but
also that Rails doesn't yet have an elegant solution.

> Otherwise what would go in the controller action?  What would we be
> calling .attributes= on?

I'm not exactly sure how the best solution would work.

I'm not certain about the owning record in this case ... <%= form_for
@post ... %> doesn't express any intent that there's going to be
multiple objects in the form ( where for example, <% fields_for
:comments %> does...

It might also require a class method on active record that would
accept multiple records to create or update. Perhaps an equivalent of
find_or_create ... that would mirror the behaviour of
accepts_nested_attributes_for ...  maybe something like:

Post.create_or_update_many( { '0' => { # create record... }, { '1' =>
{ # update record } } )

... another option would be to use some kind of presenter pattern ( <%
form_for @posts_collection ... %> ) to mock the owning record ... but
I've never been fully sold on presenters.

If there's interest in this I'd be happy to spin up a plugin or a patch.

Paul

>
> --
> Cheers
>
> Koz
>
> >
>



-- 


Paul Campbell
[email protected]
- - - - - - - - - - - - - - - - - - -
blog http://www.pabcas.com
twitter http://www.twitter.com/paulca
github http://www.github.com/paulca
phone +353 87 914 8162
- - - - - - - - - - - - - - - - - - -

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to