'Back' browser action in Ruby on Rails

Use

<%= link_to 'Back', :back %>

This is specificied in the RDoc here

This generates some Javascript to navigate backward. I've just tested it, and it works.


In Rails 3 and earlier:

link_to_function "Back", "history.back()"

In Rails 4, this method has been removed. See Andreas's comment.


This is working in Rails 5.1 along with Turbolinks.

link_to 'Back', 'javascript:history.back()'

In Rails 4.2, I got it to work with this:

<a href="javascript:history.back()">Refine Search</a>

I stole this off of @cpm’s answer, except that link_to("Refine Search", :back) didn’t do the job I wanted while pasting in the generated code <a href="javascript:history.back()">Refine Search</a> did it perfectly.