I'm using Devise for authentication in my Rails app on Heroku.
I have redirects after login and logout setup the way it's suggested to do so in the Devise wiki. (https://github.com/plataformatec/devise/wiki/How-To:-Redirect-back-to-current-page-after-sign-in,-sign-out,-sign-up,-update)
application_controller.rb:
after_filter :store_location
def store_location
# store last url as long as it isn't a /users path
session[:previous_url] = request.fullpath unless (request.fullpath =~ /\/users\/sign_in/ || request.fullpath =~ /\/users\/sign_out/ || request.fullpath =~ /\/users\/sign_up/ || request.fullpath =~ /\/users\/edit/ || request.fullpath =~ /\/ajax_utilities/ || request.fullpath =~ /\/assets/)
end
def after_sign_in_path_for(resource)
session[:previous_url] || root_path
end
def after_sign_out_path_for(resource)
session[:previous_url] || root_path
end
The redirects work fine until I enable page caching with code like this:
class AboutController < ApplicationController
def index
expires_in 1.minutes, public: true
end
end
I'm 99% sure that store_location isn't ever being called because the way page caching works in Rails the application controller would never even be reached because Rack serves the static HTTP without touching Rails.
Does anyone have any ideas about how I can take advantage of Rails page caching while also having my redirects after login/logout work correctly for Devise?
Thanks for any help.