Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Back' browser action in Ruby on Rails

Can the 'Back' browser functionality be invoked from a Rails 'Back' link?

like image 529
alamodey Avatar asked Mar 07 '09 00:03

alamodey


2 Answers

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.

like image 137
Tilendor Avatar answered Sep 22 '22 20:09

Tilendor


In Rails 3 and earlier:

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

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

like image 44
Sophie Alpert Avatar answered Sep 20 '22 20:09

Sophie Alpert