0
我有一个稍微复杂的导航系统,其中有许多着陆页,多页形式和多种访问标准CRUD功能的方式。预定义redirect_to以获得令人敬畏的导航
目标:在整个系统中维护一个变量,例如(params [:target]),以便每个控制器都知道根据link_to的位置和情况重定向用户的位置。
如何实现这个最好的方法?
- 有更好的方式来存储导航标记,因此任何控制器和方法都可以访问它们的current_user?
- 如果使用params [:target]是一个好方法(与控制器中的if或case语句结合使用以进行重定向),在添加或编辑记录时,如何将目标参数添加到表单中?例如,图说:
# customers/account.html.erb
<%= link_to "edit", :controller => "customers", :action => "edit", :id => @customer.id, :target => "account" %>
# customers/edit.html.erb
<%= submit_tag "Update", :class => "submit" %>
# how to send params[:target] along with this submit_tag so the update method knows where to redirect_to?
非常感谢你。
您可以隐藏字段,其中包含您要为submit_tag发送的参数。 – 2010-07-01 08:00:07