Rails link to current page and passing parameters to it

前端 未结 8 924

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:28

    This is what worked for me, which preserves params and protects against xss:

    = link_to_unless_current "English", url_for( request.params.merge(locale: 'en'))
    

    You could use link_to instead of link_to_unless_current

提交回复
热议问题