fields_for is purely for having more than one model in the same form. It is
not for nesting. For that, use snusu's nested attributes code (search the
list archives for details) or do what I do and just roll your own helpers to
specify the field names yourself. Not hard at all and very flexible.

..tony..

On Tue, Dec 15, 2009 at 7:07 PM, Eric Schwartz <[email protected]> wrote:

> I am trying to build a simple CRUD application with merb 1.0.15 to
> learn how to do things in merb.  I have the following views:
>
> ----- edit.html.haml ------
> .h1 edit existing vehicle
>
> = form_for(@vehicle, :action => resource(@vehicle)) do
>  = partial :form
>  = submit "Confirm"
>
> ----- _form.html.haml -----
> %h2 Maintenance Events
> %ol#maintenance_events
>  = partial "maintenance_event", :with => @vehicle.maintenance_events
>
> ----- _maintenance_event.html.haml -----
> %li
>  .event
>    = fields_for maintenance_event do
>      = text_field :description
>
> I would expect o have text_fields generated with names like
>
> vehicle[maintenance_events][][description]
>
> if the event was not already in the db, or, if the event was
> previously saved,
>
> vehicle[maintenance_events][2][description]
>
> (assuming the maintenance_event id is 2, of course).
>
> Instead, I just see
>
> maintenance_event[description]
>
> I'm sure I'm probably doing something wrong here, since this is the
> sort of thing that almost any complex web app using Merb would have
> had to have encountered long ago, but I'm not at all sure what exactly
> it is I'm missing.  I have spent the past two hours or so googling all
> over for 'merb form_for', 'merb form_for tutorial', 'merb form_for
> example' and the like, and come up with nothing, so I hope you'll
> forgive me asking such a basic question.
>
> -=Eric
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "merb" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected] <merb%[email protected]>.
> For more options, visit this group at
> http://groups.google.com/group/merb?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"merb" 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/merb?hl=en.


Reply via email to