title: Rails link to current page and passing parameters to it
body: <p>I am adding I18N to my rails application by passing the locale using url params. My urls are looking like <a href="http://example.com/en/users" rel="noreferrer">http://example.com/en/users</a> and <a href="http://example.com/ar/users" rel="noreferrer">http://example.com/ar/users</a> (for the english and arabic locales respectively).</p>
  
  <p>In my routes file, I have defined my routes with a :path_prefix option:</p>
  
  <pre><code>map.resources :users, :path_prefix =&gt; '/:locale'
  </code></pre>
  
  <p>And locale is being set using a before_filter defined in ApplicationController</p>
  
  <pre><code>def set_locale
      I18n.locale = params[:locale]
  end
  </code></pre>
  
  <p>I also defined ApplicationController#default_url_options, to add locale to all urls generated by the application:</p>
  
  <pre><code>def default_url_options(options={})
      {:locale =&gt; I18n.locale}
  end
  </code></pre>
  
  <p>What I want is to add a link in the layout header (displayed in all pages) that would link to the same page but with the other locale.</p>
  
  <p>For instance, if I am browsing the arabic locale, I want a "English" link in the header, that will redirect me back to my current page, and set the locale to english. Is there a way to do this in rails?</p>