Rails link to current page and passing parameters to it

前端 未结 8 977

I am adding I18N to my rails application by passing the locale using url params. My urls are looking like http://example.com/en/users and http://example.com/ar/users (for th

8条回答
  •  借酒劲吻你
    2020-12-13 00:22

    So I found a way to more explicitly do this with out relying on (as much) rails magic.

    url_for(params.merge({:your_new_parameter => value}))
    

    This should work in any link_to.

    All its doing is taking the current request's parameters and merging your new desired hash into them and then creating a new url for that.

提交回复
热议问题