Has_many :through, nested polymorphic relations?

It should be noted now that Rails 3.1 has nested has_many :through associations built in an ASCIIcast on this.

It should be noted now that Rails 3.1 has nested has_many :through associations built in. An ASCIIcast on this.

As far as I know, ActiveRecord does not support :through a :through relationship. You can work around this using some tricks and hacks, such as creating a VIEW which remaps the relationship into a more direct one, which can simplify your ActiveRecord model at the expense of database complexity. Polymorphic associations are particularly ornery.

Thanks just wanted to be verify that with someone else. – Scott Markwell Sep 8 '09 at 16:43.

I'm not sure of its support for nesting through polymorphic asociations but it might be worth checking out the nested_has_many_through plugin, which from the README: …makes it possible to define has_many :through relationships that go through other has_many :through relationships, possibly through an arbitrarily deep hierarchy. This allows associations across any number of tables to be constructed, without having to resort to find_by_sql (which isn't a suitable solution if you need to do eager loading through :include as well).

Yes, this will work. You just have to be careful not to nest too deeply and bog down your app. I wrote a blog post showing the step-by-step: kconrails.Com/2010/01/28/… – Jaime Bellmyer Oct 23 '10 at 3:14.

Try this (Rails 3): class LayerOne all. Map(&:id)) end end end.

But this approach doesn't take into the account of the previously specified has_many relations through the polymorphic relation. It may not be possibly through the existing rails conventions, but figured I'd defer the question to people smarter then myself.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions