I felt annoyed enough when having to redirect user back to their previous location in a hackish way that I wrote this plugin.
It avoids storing POST and Ajax request. It also has a facility to specify actions not to store in the history.
In your app/controllers/application_controller.rb, add a history line like this:
class ApplicationController < ActionController::Base
history :default => "http://default.url.com/", :max => 10
end
The history function accepts a hash of options
None of the parameters are required. If somebody knows of a better way to obtain the default URL, he is welcomed to tell me how.
You can use the method history_skip in your controller if you want to avoid certain location to be stored in the history. By default, action resulting from a POST request or an Ajax request are not stored in the history.
class FooController < ApplicationController
history_skip :action_to_skip
def action_to_skip
# I will not be stored in the history
end
end
In your actions, you can then use the following methods:
Q: how can I get this plugin?