Forum: Ruby on Rails RE: One To Many To Many

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
60e38de043848f82392062088f191213?d=identicon&s=25 Hogan, Brian P. (Guest)
on 2006-02-24 16:58
(Received via mailing list)
You can't as far as I know... (someone correct me if I'm wrong
please...)
But you can make it work.


Not tested but it's similar to something I did before.

In the client model, do this

	def line_items
        items = Array.new
        for order in self.orders
          items << order.line_items
	  end
	  items
      end

Then you can do client.find(1).line_items

If that makes you cry because of performance reasons, then you might
want to replace that logic with a simple select statement and use
find_by_sql
This topic is locked and can not be replied to.