Rails中的多态路由 - 在视图中

Ell*_*iot 2 ruby-on-rails

我将Comment作为多态模型.

它附在Post,Review等上.

我在CommentsController中也有一个动作,叫做test.

我有我的路由设置,所以test_post_comment_path工作(调用testCommentsController中的操作).

问题是,在我的部分视图中,我希望该路线能够根据当前动作进行更改,即.它是test_post_comment_path在帖子上和test_review_comment_path审查时.

小智 5

正确的方法是使用polymorphic_url ...