Polymorphic Routes in Rails - in Views
I have a comment as a polymorphic model.
It is attached to a post, review, etc.
I also have an action in the CommentsController called test
.
I have my routes setup, so it test_post_comment_path
works (to call the action test
in the CommentController).
The problem is that in my partial view, I want this route to be able to change depending on the current activity, i.e. it test_post_comment_path
is when on column and test_review_comment_path
when on review.
source to share
Just use two different paths?
I mean: you don't want to inject so much logic inside the routes.
If the routes are trying to do more than routing the first time something goes wrong, you are in serious trouble.
In your partial view, the logic for creating specific links or other html comment stuff should go in the helper.
source to share