开发者

Rails: change URL response format

开发者 https://www.devze.com 2022-12-30 01:55 出处:网络
How to easily change the format of URL in a right way: /comment/10.js?param1=6 to /comment/10?param1=6 Preferrably with some URL library or so, not with regexps.

How to easily change the format of URL in a right way:

/comment/10.js?param1=6

to

/comment/10?param1=6

Preferrably with some URL library or so, not with regexps.

Use case: redirect back with request.request_uri s开发者_StackOverflow中文版aved in session.


I'm not quite sure the use case, but the simplest way would be in the controller

respond_to do |f|
  f.js { redirect_to #copy url params, but set :format to what you actually want }
end
0

精彩评论

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