ruby -- 问题解决(五)页面返回跳转

今天在做页面跳转的时候,google了下页面跳转的方法,

跳转到上一个页面:redirect_to :back

<%= link_to "返回" ,:back %>

这个方法虽然不错,但是会造成回路。

于是寻求更好的方法,找到一个不错的解决方法,链接:http://blog.sina.com.cn/s/blog_4bc3b0d10100q3co.html

然后再继续寻找更好的解决方法,原文链接:http://stackoverflow.com/questions/5740934/jquery-mobile-back-button

use the attribute data-rel="back" on the anchor tag instead of the hash navigation, this will take you to the previous page

在controller中加上,

@url = request.url

在页面中加上,

<%= link_to "返回" ,@url,{"data-rel" => "back"} %>

如果你想加上返回的图标,那么修改如下:

<%= link_to "返回" ,@url,{"data-icon" => "back" , "data-rel" => "back"} %>

附温馨提示:  request.url:获取当前页面的地址

原文地址:https://www.cnblogs.com/lmei/p/3234070.html