0

In otherform.erb I have

<%= link_to "Back", redirect "/" %>

But then I can't even view the front page when I start my server, even without pressing anything. It gives me syntax error, unexpected keyword_end, expecting ')' ...k_to "Back", do erb :index end ).to_s); @_out_buf.concat "... ... ^

So what's the proper way to control the back button in ruby, in the erb documents?

a person
  • 1
  • 2

1 Answers1

0

Just use

redirect_to :back
# is a shorthand for:
redirect_to request.env["HTTP_REFERER"]

Going back to root it's a "homepage" link, not a "back" link.

Miguel Cunha
  • 663
  • 8
  • 16
  • I want to redirect the user to the homepage, anytime when they click the back button. – a person Jul 28 '15 at 12:55
  • So add `root :controller => 'static', :action => '/' ` to your routes and then you can use `redirect_to root_path` where you need. Assuming that you have a public/index.html, that will work! – Miguel Cunha Jul 28 '15 at 13:05
  • I am not using rails. Is there a way to do it without rails? – a person Jul 28 '15 at 13:09