Forum: Ruby on Rails link_to or helper to generate a javascript:history.back() ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-17 15:06
(Received via mailing list)
Hello,

There is an link_to option or an helper that generate a link like :

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

Thanks
071aec714fe5f3fe5b1df9fc5adb45f2?d=identicon&s=25 Raghuraman Suraj (Guest)
on 2006-01-17 15:12
(Received via mailing list)
you can use link_to "Back", "javascript:histroy.back()"
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-01-17 15:12
(Received via mailing list)
oo00oo wrote:
> Hello,
>
> There is an link_to option or an helper that generate a link like :
>
> <a href="javascript:history.back()">Back</a>

<%= link_to_function 'Back', 'history.back()' %>

Should do the trick...
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-17 15:33
(Received via mailing list)
Ok thanks, so no helper or option like :back => true
:)
6dab365a82517fb694650a57ee88e4a4?d=identicon&s=25 Guest (Guest)
on 2006-01-17 20:30
oo00oo wrote:
> Ok thanks, so no helper or option like :back => true
> :)

Or you can add this to your ApplicationHelper.rb

def link_back
  return link_to_function 'Back', 'history.back()'
end

Then in your views:
<%= link_to_back %>
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (olbrich)
on 2006-01-17 22:57
Guest wrote:
> oo00oo wrote:
>> Ok thanks, so no helper or option like :back => true
>> :)
>
> Or you can add this to your ApplicationHelper.rb
>
> def link_back
>   return link_to_function 'Back', 'history.back()'
> end
>
> Then in your views:
> <%= link_to_back %>

You can also use 'redirect_to :back' which will send you back to the
referring page... not quite the same thing.

_Kevin
26f23b6c24be0a33c4c53e66496fcb7d?d=identicon&s=25 Guest (Guest)
on 2006-01-18 02:41
Guest wrote:
> oo00oo wrote:
>> Ok thanks, so no helper or option like :back => true
>> :)
>
> Or you can add this to your ApplicationHelper.rb
>
> def link_back
>   return link_to_function 'Back', 'history.back()'
> end
>
> Then in your views:
> <%= link_to_back %>

you mean
<%= link_back %>
This topic is locked and can not be replied to.