I need to check in a rails controller whether the user used the back button to come back to the page. Is there a specific method for this?
R – How to tell in Rails controller whether user used back button
ruby-on-rails
Related Question
- Ruby-on-rails – How to get the name of a Ruby class
- Ruby-on-rails – How to understand nil vs. empty vs. blank in Ruby
- Ruby-on-rails – Rails: How to rename a database column in a Ruby on Rails migration
- Ruby-on-rails – How to redirect to previous page in Ruby On Rails
- Ruby-on-rails – How to get the current absolute URL in Ruby on Rails
- Javascript – Using Rails 3.1, where do you put your “page specific” JavaScript code
- Ruby-on-rails – How to use concerns in Rails 4
- Ruby-on-rails – Getting error: Peer authentication failed for user “postgres”, when trying to get pgsql working with rails
Best Solution
Telling that a user used the back button is very hard (maybe impossible?) for the reason Shtééf commented already.
But, you can make sure the page is fetched again from your webserver (instead of grabbed from the local cache), by sending some custom headers with it telling that the page should not be cached. More information on these headers can be found on Best way to disable client caching, Why both no-cache and no-store should be used in HTTP response? or take a look at these questions.
If you keep track on which page(s) the user has been you can see whether s/he returned to the previous page, which might indicate that the back button was used.