Hadmut wrote:
You could use restful routing.
Well, I had a view on that restful routing thing and found that I
can't use it, it breaks some
of the functionality.
I had a special action in my rails application that gets the
caller's :controller, :action, and :id to enable
returning to the page where it came from. This was easy since
redirect_to would take variables as
parameters.
I do not see how this would work with restful routing, since it
defines fixed macros for the pathes.
Who decided to use restful routing with rails?
To your first question, you should have a route in your routes.rb that
looks like:
map.connect ':controller/:action/:id'
That is how you want it to stay compatible with your old rails app.
Restful routes look more like:
':resource_name/:id/:optional_action'
Where optional action is not a basic CRUD operation (new, edit, promote,
rate, etc.) So make sure your defined routes are the right format.
Now to keep track of where a user was, you dont need to
controller/action/id. You can capture the URI of the request. In your
controller, you can do
def save_location
session[:return_to] = request.request_uri
#=> "/some/path_to/something/123"
end
def restore_location
redirect_to session[:return_to]
end
So rather than controllers and actions, you simply capture the string
url path, and it works great with redirect_to.