我有一个我无法解决的简单问题:
在我的RoR控制器中,我有经典的
format.html {redirect_to @document, notice= 'Document was successfully created.'}
但我想将其重定向到特定页面:例如
redirect_to /page/document/:id_document
你有确切的语法吗?谢谢!
答案 0 :(得分:1)
在终端中运行 rake routes
,根据您的路线显示路径或网址帮助方法
your_helper GET /page/document/:id_document {:action=>"action_name", :controller=>"controller_name"}
然后做
format.html {redirect_to your_helper_path(@document), notice= 'Document was successfully created.'}
或强>
你也可以使用像@jvnill
建议的
format.html {redirect_to [:page, @document], notice= 'Document was successfully created.'}