title: conditionally apply skip_before_filter with :if => condition in rails 4
body: <p>I have an <code>Events</code> Controller on which I want to skip authentication incase the event is public. </p>
  
  <p>In my <code>ApplicationController</code> I have this call to devise's <code>authenticate_user!</code></p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    before_action :authenticate_user!
  end
  </code></pre>
  
  <p>now, Inside my Events table, I have a boolean field called <code>public</code>. I use that to check if event is public or not. Like this in <code>EventsController</code></p>
  
  <pre><code>class EventsController &lt; ApplicationController
    skip_before_action :authenticate_user!, only: :show, if: Proc.new { :is_public? }
  end
  </code></pre>
  
  <p>But for some reason, this didn't work. so I had to do this:</p>
  
  <pre><code>class EventsController &lt; ApplicationController
    skip_before_action :authenticate_user!, only: :show
    before_action :authenticate_user!, unless: :is_public?
  
    def is_public?
      @event.present? &amp;&amp; @event.is_public
    end
  end
  </code></pre>
  
  <p>This works as expects and skip authentication if <code>@event.public = true</code> because the above repeats the <code>before_filter</code> with the inverse condition after skipping.</p>
  
  <p>I am wondering:</p>
  
  <ol>
  <li>what I did is correct?</li>
  <li>Does this have any performance impact. if yes, then Is there a better way?</li>
  </ol>