How can I reload the current page in Ruby on Rails?

For my application, I use redirect_to :back and it does the trick. However, I doubt this might have an error in a non general use case(s) (user came from a special page?) but i haven't found it so far in my app.


If you're looking for a way to get the page to refresh (typically redirect_to :back) with an XHR request, you don't have to look for a way to change the response type - just tell the page to reload with inline JS.

format.js { render inline: "location.reload();" }

Like Elena mentions, this should go in a respond_to block, like so:

respond_to do |format|
  format.js {render inline: "location.reload();" }
end