rubyonrailsin

A Ruby and Rails talk

Wednesday, March 10, 2010


[Rails] Re: belongs_to :through

by rubyonrailsin 0 comments



Share this post:
Design Float
StumbleUpon
Reddit

Joaquin Rivera padron wrote:
> hi there,
> lets say you have: A that belongs_to :b, and B belongs_to :c
>
> how do you normally go about saying A belongs_to :c, :through => :b ??

If A belongs_to :b, that means that Rails expects a b_id field in A's
table. In your case, that doesn't exist, so what you want is
A has_one :c, :through => :b

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive