6

I am fairly new to ruby on rails, and am experimenting with the structure and functionality of RoR and want to know how to create a simple reload link using RoR instead of the static HTML way

Stacker-flow
  • 1,251
  • 3
  • 19
  • 39

4 Answers4

14
link_to "reload", url_for(params)
bubblez
  • 814
  • 1
  • 8
  • 14
3

If you just do an empty string for the url: <%= link_to "Refresh", "" %>, that will link back to current page. Assuming you want to clear the params.

If you want a refresh with the params then do as @bubblez answered:

<%= link_to "Refresh", url_for(params) %>.

RebelOfBabylon
  • 658
  • 5
  • 12
0

It is better to keep it doing with Javascript. Rails could help you in case you want to redirect.

techvineet
  • 5,041
  • 2
  • 30
  • 28
0

I'm not entirely sure why you want to just reload the page. (Probably need a bit more context) but you could just generate a link on the page that will reload it like this:

<%= link_to "reload", root_path %>

That will just output a link to the root_path, you can redirect back to whatever page you are currently on by changing the second parameter in the link_to helper. For list of routes, run "rake routes".

derekyau
  • 2,936
  • 1
  • 15
  • 14
  • I have a list of URL's that RoR fires off and presents the response code from the given URL's so I can quickly present environments that are up or down etc – Stacker-flow Sep 12 '13 at 09:27
  • What do you mean by fires off? Are you doing this asynchronously? – derekyau Sep 12 '13 at 09:29
  • Well I am using Net:HTTP to go to the URL I have defined and present back the response code next to the URL – Stacker-flow Sep 12 '13 at 09:30
  • Okay, starting to make more sense.. So you want the page to just reload and essentially refresh all of these statuses? – derekyau Sep 12 '13 at 09:32
  • 1
    If thats the case, I would go for a simple link_to call with a path back to your current page, or simply do it through JS – derekyau Sep 12 '13 at 09:33
  • What is your current controller and controller action that renders this view? – derekyau Sep 12 '13 at 09:35