Few days ago I created a polymorphic comment model based on Railscasts.
Today I wanted to show the lastest comments on homepage and link each comment body to their ‘parents’ like a book or a movie.
The link path was a bit tricky and finally I figured it out.
What you need here is this particular comment’s commentable type like ‘book’ or ‘movie’, as well as the commentable id, so it will leads you to the show page and the url should like ‘book/id’.
The view page could look like this.
This will direct to the page that I want.