Search code examples
ruby-on-railsauthenticationbefore-filter

How to set a before_filter for every controller bar one?


In Ruby on Rails, I would like to add a before_filter to every controller except for one. Currently I have in ApplicationController:

before_filter :authenticate

Is there a way to apply this rule inside ApplicationController rather than adding before_filter :authenticate in every controller except the public controller?


Solution

  • Put the before filter in ApplicationController and then skip it in the controller where you don't want it:

    skip_before_filter :authenticate