开发者

Ruby on Rails: How to create a "recent_search_path" helper method?

I have implemented a search feature of my application. After submitting a search term, you are redirected to a url that looks something like this:

http://localhost:3000/search?utf8=✓&search=term

I want to be able to store this in the session and link to it later:

<%= link_to 'Back', recent_search_开发者_JAVA技巧path %>

How might I achieve this?


Thanks to rc for referring me to a very similar question. This could be achieved by storing the current path in the session:

session[:recent_search_path] = request.url

...and retrieving it again in the view:

<%= link_to "Back to search results", session[:recent_search_path] %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜