title: Rails, changing the class attribute of a an HTML element when clicking on it
body: <p>I am implementing the view of a mailbox system. I wanna have <strong>Inbox</strong> and <strong>Sent</strong> mailboxes. Therefore I place two links in my view such as:</p>
  
  <pre class="lang-rb prettyprint-override"><code>&lt;%= link_to "Inbox", messages_user_path(current_user),:class =&gt;"current", :which_mailbox =&gt; "received" %&gt;
  &lt;%= link_to "Sentbox", messages_user_path(current_user),:class =&gt;"current", :which_mailbox =&gt; "sent" %&gt;
  </code></pre>
  
  <p>And then I expect my controller to fetch the appropiate messages according to `params[:which_mailbox]. Such as:</p>
  
  <pre class="lang-rb prettyprint-override"><code>def fetch_messages
      if params[:which_mailbox] == "received"
        @messages= current_user.received_messages
      else if params[:which_mailbox] == "sent"
        @messages = current_user.sent_messages
      end
  
      render 'users/messages_page'
  end
  </code></pre>
  
  <p>I want to style the selected mailbox( i.e. `class="current") using bold fonts, in contrast to the other option.</p>
  
  <pre><code>a .current{
      font-weight: bold;    
  }
  </code></pre>
  
  <p>The <strong>problem</strong> is that both options ( Inbox/Sentbox) have <code>class="current"</code> using the <code>link_to ..</code> code above. How can I activate/deactivate this class? Is it possible to do without Javascript? That is just using Rails+ CSS? </p>
  
  <p><strong>EDIT</strong>
  This is the generated HTML:</p>
  
  <pre class="lang-rb prettyprint-override"><code>    &lt;section&gt;
    &lt;a href="/users/1/messages" class="current" which_mailbox="received"&gt;Inbox&lt;/a&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;a href="/users/1/messages" class="current" which_mailbox="sent"&gt;Sent&lt;/a&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>I realize now that there is no <code>params[:which_mailbox]</code>, I guess I should initialize the key <code>which_mailbox</code>, where is the recommended place do that?</p>