How bout...
a = Author.find(some_id)
a.update_attribute(middle_name, "Poindexter")
a.stories.find_by_title("The Lake").update_attribute(title, "The Dry Lake")
Peter
On 10/1/07, Glenn Little <[EMAIL PROTECTED]> wrote:
> Sorry, fixing confusing typo:
>
> Glenn Little wrote:
> > Say I have a couple of tables:
> >
> > author :has_many => stories
> > story :belongs_to => author
> >
> > In a form handler I'd like to do something like:
> >
> > a = Author.find(some_id)
> > a.middle_name = "Poindexter"
> >
> > s = a.find_by_title("The Lake")
> > s.title = "The Dry Lake"
> >
> > I'd like to then transactionally (or even not) do
> >
> > a.save!
> >
> > and have the change to "s" get saved as well. Is this possible?
> > It works fine if s is a new record created with build(), or something like
> > s = Story.new
> > a.stories << s
> > a.save!
> >
> > Is there any magic like "<<" or build() that can be used for existing
> > objects to attach them to a parent object for purposes of
> > cascading the save()?
> >
> > Thanks!
> >
> > -glenn
> _______________________________________________
> Sdruby mailing list
> [email protected]
> http://lists.sdruby.com/mailman/listinfo/sdruby
>
--
"A flute with no holes is not a flute,
and a doughnut with no hole is a Danish."
- Zen philosopher, Basho
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby