Link_to or helper to generate a javascript:history.back()?


#1

Hello,

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

Back

Thanks


#2

you can use link_to “Back”, “javascript:histroy.back()”


#3

oo00oo wrote:

Hello,

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

Back

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

Should do the trick…


#4

Ok thanks, so no helper or option like :back => true
:slight_smile:


#5

oo00oo wrote:

Ok thanks, so no helper or option like :back => true
:slight_smile:

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 %>


#6

Guest wrote:

oo00oo wrote:

Ok thanks, so no helper or option like :back => true
:slight_smile:

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


#7

Guest wrote:

oo00oo wrote:

Ok thanks, so no helper or option like :back => true
:slight_smile:

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 %>