Chris, I'd love to see a recipe. I'm trying to do the very same thing right now.
Thanks, MIke On May 5, 6:45 pm, Chris Apolzon <[email protected]> wrote: > I figured I'd update this post with the solution I worked my way to. > > In my model, Manuscript.rb the relevant lines: > has_one :timeline > accepts_nested_attributes_for :timeline > In the ManuscriptsController, we need to setup a timeline object in the new > actions. Would also need to happen in update if there was no timeline on > load > def new > hobo_new > @manuscript.build_timeline > end > > And finally, the piece of glue that makes this all work with Hobo: > <field-list fields="title, msid, status, article_type, coauthors, > primary_author, timeline.duration" param> > <timeline_duration-view:><input > name="manuscript[timeline_attributes][duration]"/></timeline_duration-view:> > </field-list> > (I'm sure this will get abstracted into its own tag as I progress through > the rest of my project). The name field must be called timeline_attributes > so that Rails knows to save it in a dependent model. > (accepts_nested_attributes_for creates the timeline_attributes=() method on > the model to make this all work). > > As always, I'd love criticism, but if this actually looks correct and > proper, I'd be glad to write up a recipe for it. > > -Chris > > > > On Wed, May 5, 2010 at 1:07 PM, Chris Apolzon <[email protected]> wrote: > > Having trouble saving a dependent model on a single form in Hobo. > > Because this is a has_one relationship, Hobo's out of the box multi- > > model forms won't handle it. I'm pretty new at rails so I've been > > reading and watching RailsCasts, especially episode 73. In this > > episode, he makes it seem pretty simple to do what I'm looking for > > using virtual attributes and fields_for to setup the form. > > @manuscript.build_timeline works fine, but I'm not sure how I should > > go about updating the Hobo form. If I go off and create a vanilla > > form using form_for and fields_for, I assume I'll be circumventing > > some of Hobo, but I don't know how much. From my cursory knowledge of > > Hobo, I would guess that this will not go through the hobo permission > > system? Are there other drawbacks with this approach? > > > Thanks. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Hobo Users" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<hobousers%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/hobousers?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Hobo Users" 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 > athttp://groups.google.com/group/hobousers?hl=en. -- You received this message because you are subscribed to the Google Groups "Hobo Users" 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/hobousers?hl=en.
