开发者

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

开发者 https://www.devze.com 2023-03-06 21:07 出处:网络
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:

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

精彩评论

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