In rails, how do I display a list of the lastest 5 pages the current user has visited?
I know that I can do redirect_to(request.referer) or redirect_to(:back) to lin
You can put something like this in your application_controller:
class ApplicationController < ActionController::Base
before_filter :store_history
private
def store_history
session[:history] ||= []
session[:history].delete_at(0) if session[:history].size >= 5
session[:history] << request.url
end
end
Now it store the five latest url visited