【发布时间】:2010-01-20 18:52:21
【问题描述】:
我有一个多态模型评论,它可以与许多类型的评论相关。 例如,在我的溃败中,我有:
map.resources :newsitems do |news|
news.resources :comments
end
一切正常,唯一的问题是生成路径。 我在我的视图/控制器中有 @commentable 项目,我从 before_filter 检索。
指向 [@commentable, @comment] 的链接可以正常工作,例如表单、显示或销毁。 但是指向 new 和 edit 的链接很乱... cmets_path(@commentable, @comment) 例如不起作用。
如何在我的视图中构建这条动态路径?
尤其是 edit_ 和 new_ 路径
【问题讨论】:
标签: ruby-on-rails path polymorphic-associations