It does work – except that when you click on that link, you go from
your current page to the ‘back’ action, which will redirect you back to
the current page. Why? Because your current page will effectively be the
referrer URL! What you need is a helper called link_to_back or so, which
will return the value of link_to request referrer. I actually have found
it nice to have link_to_back to take in a :default option because you
may not always have a referring page.
I supspected that this may be the case (because there were no errors),
but didn’t know how to do it in another way.
Now I’ve got something like this:
def link_to_back(text)
link_to text, request.env[“HTTP_REFERER”]
end
How can i add this default parameter (as a hash) that you’ve mentioned?
And one more thing - is there an easy way to check if user has
javascript enabled? I could do:
link_to_function text, “history.go(-1)”
and if user doesn’t have javascript call
link_to text, request.env[“HTTP_REFERER”]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.