Has_many through polymorphic?

I don't think Rails supports has_many :through passing through polymorphic associations In Rails 3.1 rc 1, I get an explicit exception in the rails console: ruby-1.9.2-p180 :011 > p Folder.first. Users Folder Load (0.1ms) SELECT "folders". * FROM "folders" LIMIT 1 ActiveRecord::HasManyThroughAssociationPolymorphicThroughError: Cannot have a has_many :through association 'Folder#users' which goes through the polymorphic association 'Folder#parent.

I don't think Rails supports has_many :through passing through polymorphic associations. In Rails 3.1 rc 1, I get an explicit exception in the rails console: ruby-1.9.2-p180 :011 > p Folder.first. Users Folder Load (0.1ms) SELECT "folders".

* FROM "folders" LIMIT 1 ActiveRecord::HasManyThroughAssociationPolymorphicThroughError: Cannot have a has_many :through association 'Folder#users' which goes through the polymorphic association 'Folder#parent'.

I am accepting this answer since I doubt much more will come, I end up hitting a wall most of the time I want to use has many through :/ – Schmurfy Aug 5 at 19:36.

Here's a gotcha: has_many :through associations do not support polymorphic access to the associated object. In this article I'll show the reasons for this limitation, and also provide an approach that lets you work with polymorphic associations without too much trouble. Let's start with some example code so I have something concrete to talk about.

Here's some models for representing that an author can write either articles or books, and that each article or book can have multiple authors.

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