Polymorphic association in reverse
- by Erik
Let's say that I have two models - one called Post and one other called Video. I then have a third model - Comment - that is polymorphically associated to to each of these models.
I can then easily do post.comments and video.comments to find comments assosciated to records of these models. All easy so far.
But what if I want to go the other way and I want to find ALL posts and videos that have been commented on and display these in a list sorted on the date that the comment was made? Is this possible?
If it helps I'm working on Rails 3 beta.