简体   繁体   中英

How to create simple refresh page link with Ruby on Rails

我对rails上的ruby相当新,并且正在尝试使用RoR的结构和功能,并想知道如何使用RoR而不是静态HTML方式创建简单的重新加载链接

link_to "reload", url_for(params)

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

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

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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM