I started using i18n with my app, but all the pages that i access by passing a parameter with the link_to isn't working.
so, let's say i'm currently on this page
/ar/browse?type=art
that i got to via clicking on this link_to
<%= link_to "/ART/", browse_url(:type => "art")%>
then i decided to change the language via clicking on this:
<%= link_to_unless_current "en", locale: 'en', :class => 'my-navbar-link' %>
after changing the language, that's what i get directed to
/en/browse?class=my-navbar-link
the type parameter get lost after i change the language. and as a result it doesn't direct me to the correct page
hope i made it clear. i'm not sure how i can fix it :/
thank you in advance.
You are incorrectly passing arguments to link_to_unless_current
. The following is what you need to do:
link_text = "en" # or whatever you like
html_class = "my-navbar-link"
link_to_unless_current link_text,
{locale: "en", type: params[:type]},
{class: html_class}
i.e. you need to separate the link options from the HTML options.