Get url for current page, but with a different format

后端 未结 3 1949
我寻月下人不归
我寻月下人不归 2021-01-04 02:14

Using rails 2. I want a link to the current page (whatever it is) that keeps all of the params the same but changes the format to \'csv\'. (setting the format can be done b

3条回答
  •  鱼传尺愫
    2021-01-04 02:40

    @floor's answer was great, I found it very useful.

    Although the method can be improved by using the to_params method rather than contructing your own, like so:

    def current_url(new_params)
      params.merge!(new_params)
      "#{request.uri}#{params.to_params}"
    end
    

提交回复
热议问题