title: How to pass a selected_tab to a controller action?
body: <p>I have a main tab 'Category'. This tab has two more tabs as 'question' and 'answer'. I have created <code>CategoryController</code>, in which I have defined two actions with the name 'question' and 'answer'. I have a method <code>category_type</code> in private which should take category_type based on which tab is selected ('question' or 'answer'). This method will be called in the controller's actions. I have created these tabs in views and have also added the routes. How to pass which tab is selected from view to this method?</p>
  
  <p>I have created a partial for these tabs and rendered it on the main page. </p>
  
  <p><code>_tabs.html.haml</code></p>
  
  <pre>
  
  #secondary-slider.pills-container
    %span
      = link_to 'Questions', question_category_path, class: @selected_tab[:question]
    %span
      = link_to 'Answers',  answer_category_path, class: @selected_tab[:answer]
  
  </pre>
  
  <p>Controller's action:</p>
  
  <pre>
  
    def question
      @selected_tab = { category_type => :selected }
    end
  
    alias :question :answer
  
    private
  
    def category_type
      @category_type = :question
    end
  
  </pre>
  
  <p>Instead of passing category_type as <code>:question</code> or <code>:answer</code> as given above, I want to pass params from view i.e. it if <code>question</code> tab is selected, the <code>@category_type</code> should be passed with <code>question</code> else if <code>answer</code> tab is selected, it should be passed in <code>category_type</code>. </p>
  
  <p>How can this be achieved? I thought of passing 'params()' but couldn't figure out what should be passed in the parenthesis. </p>
  
  <p>Thanks in advance.</p>