polymorphic_url
polymorphic_url([:admin, @article, @comment]) => admin_article_comment_url(@article, @comment) 以后再也不用路径发愁了
polymorphic_url([:admin, @article, @comment])
admin_article_comment_url(@article, @comment)
配合这个使用效果更佳
def find_commentable params.each do |name, value| if name =~ /(.+)_id$/ return $1.classify.constantize.find(value) end end nil end
http://railscasts.com/episodes/154-polymorphic-association
这的确是好东西