views:

26

answers:

1

I have a slightly complex navigational system with numerous landing pages, multipage forms, and multiple ways of accessing the standard CRUD functions.

Objective: To maintain a variable such as (params[:target]) throughout the system such that each controller knows where to redirect a user based on the location and circumstances of the link_to.

How to implement this the best way?

  • Is there a better way to store navigation markers so any controller and method can access them for the current_user?
  • If using params[:target] is a good way to go (combined with if or case statements in the controller for the redirect), how do I add the target params to the form when adding or editing a record? For example, view says:
# 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?

Thank you very much.

A: 

I think you could get the same result by setting a session[:target] each time is necessary. so you'll always know where to redirect from controllers without changing *link_to* params and leaving clean URLs.

hope this helps, a.

apeacox