On Tue, Oct 11, 2011 at 11:52 PM, Robert Walker <[email protected]>wrote:

> Robert Walker wrote in post #1026165:
> > Peter Vandenabeele wrote in post #1026116:
> >> * actually, I believe what you propose above will not work, it would
> >> probably be
> >>
> >>  @user.build_referral # untested
> >
> > Actually, your believe isn't accurate. You should have tested. :)
> >
> > See collection.build and collection.create explained here:
> >
> >
>
> http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_many
>
> Sorry, I just realized that is is a has_one rather than has_many, so
> please disregard previous reply.
>

No prob. In reference to


http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

I have always been curious why the format of the association methods
is so different for the singular compared to collection associations. This
then
leads to confusion as shown above ...

  has_many => self.others.xxx (many methods added by has_many)
  has_one => self.{build|create}_other

Maybe for the singular association, we could add

  self.other.build
  self.other.create
  self.other.create!

to make it more uniform ?

HTH,

Peter

-- 
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