What you're describing would look like:

membership.build_role.save!

What I'm talking about is:

membership.create_role
membership.save

--Matt Jones

On May 21, 5:07 pm, Brian <[email protected]> wrote:
> On May 21, 3:38 pm, Matt Jones <[email protected]> wrote:
>
> > Also, have you tried calling membership.save in your original example?
> > The code you show will set the FK in membership (via
> > membership.create_role), but it's not on the DB until you save it...
>
> > --Matt Jones
>
> This lead me to believe 
> otherwise:http://guides.rubyonrails.org/association_basics.html#has-one-associa...
>
> Specifically, "The create_association method returns a new object of
> the associated type. This object will be instantiated from the passed
> attributes, and the link through its foreign key will be set. In
> addition, the associated object will be saved (assuming that it passes
> any validations)."
>
> Is the guide wrong about this being saved?  In any case, I actually
> did try this with the build_association followed by a .save! and got
> exactly the same results.
--~--~---------~--~----~------------~-------~--~----~
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 [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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to