Preventing the back action after logout in Rails.

Umesh Kafle
Aug 28, 2017 · 1 min read

While working on the rails project I have found that once the logged in user logout from the application and press the browsers back button the user get redirected to the page that should only be viewed to the logged in user.

To resolve this issue I have added a action to the application_controller.rb

This works fine in my chrome and firefox browser but to make it work in safari too I have added added a javascript onunload function to my application.htm.erb

This woks fine in all three browser.

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade