简体   繁体   中英

rails link_to ajax remote: :true changed the request.original_url

Before: request.original_url = xxx.xxx.xxx/?locale=en&page=14

After a success Rails remote: :true Link_to as:

link_to x.name, blog_path(:blog=>{:role_id=>x.id, :blog_like => 1}, :url=>request.original_url, :page=>params[:page]),method: :post, remote: true

The request.original_url change to = xxx.xxx.xxx/blog/9?role_id=402&url=xxx.....

I know this sound correct as it just did a post update, but, as this is a partial AJAX update, I have another feature need to refer this page's current url, how can I get it?

The request.referer did come back with right current page url, however, it is previous page url when just into this page, which, correct of course, just difficult to use...

I found the solution: 1. for remote: :true, it will change the request.original_url, so, keep/save the original_url at the calling controller. 2. store original url at params might be a bad idea, I changed to save in session, as it no longer show at url, it won't keep growing in params

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