rubyonrailsin

A Ruby and Rails talk

Wednesday, March 10, 2010


[Rails] belongs_to :through

by rubyonrailsin 0 comments



Share this post:
Design Float
StumbleUpon
Reddit

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

searching I found two solutions:

1. method:
class A
def c
  b.c
end
end

and

2.delegate:
class A
delegate :c, :to => :b
end

but neither will have the benefits of generated sql with joins.

How you normally do this? and What are the reasons against having it on rails itself?

greetings
joaquin

--
www.least-significant-bit.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