0

I want to create 3 links:

  • Popularne - /
  • Nowe - /?order=1
  • Najlepsze - /?order=2

Below code creates these links. Now, depends on params[:order] I want set this link to class="active". I setup <%= debug(params) if Rails.env.development? %> and when I click for example Nowe it shows me order: '1' but looks like this if statement with params[:order] doesn't work, and it is not generating class="active". It works only for Popularne. Any idea where is a problem? Looks like it's params[:order].

  <ul class="navbar">
    <li><%= !params[:order] ? link_to("Popularne",{},:class=>"active"):link_to("Popularne")%></li>
    <li><%= params[:order] == 1 ? link_to("Nowe",:order=>1,:class=>"active"):link_to("Nowe",:order=>1)%></li>
    <li><%= params[:order] == 2 ? link_to("Najlepsze",:order=>2,:class=>"active"):link_to("Najlepsze",:order=>2)%></li>
  </ul>
4

0 回答 0