title: Rails common filters for controllers
body: <p>I have some common filters that I use for two controllers. The filters are exactly the same however the skip conditions are different in both the controllers. </p>
  
  <p>In u_controller:</p>
  
  <pre><code>  before_filter :require_login,:get_notification,:get_credits
  
    skip_before_filter :require_login , :only =&gt;  [:index,:registration,:login,:oauthlogin,
                                                  :forgotpassword,:invite_mail,:newpassword,
                                                  :changepassword,:invite,:verify,:terms,:privacy,:about]
    skip_before_filter :get_notification , :only =&gt; [:registration,:login,:oauthlogin,
                                                  :forgotpassword,:invite_mail,:newpassword,
                                                  :changepassword,:invite,:verify]
    skip_before_filter :get_credits , :only =&gt; [:registration,:login,:oauthlogin,
                                                  :forgotpassword,:invite_mail,:newpassword,
                                                  :changepassword,:invite,:verify,:terms,:privacy,:about]
  </code></pre>
  
  <p>In q_controller:</p>
  
  <pre><code>before_filter :require_login,:get_notification,:get_credits,:require_auth
  
     skip_before_filter :get_notification,:get_credits,:require_auth,
                        :only =&gt; [:topic_suggest,:upload,:new_question,:qdb,:post_new_question,:evaluate_answer,:image]
     skip_before_filter :require_auth, :only =&gt; [:add]
  </code></pre>
  
  <p>What would be the best practice in such a scenario, to solve the following problem:</p>
  
  <ol>
  <li>Avoid duplicate declaration of filters in the two controllers</li>
  <li>Use cleaner code instead of <code>skip_before_filter</code>. </li>
  </ol>