Search code examples
ruby-on-railsrubyruby-on-rails-4crud

Rails 4: before_filter vs. before_action


In rails >4.0.0 generators creates CRUD operations with before_action not before_filter. It seems to do the same thing. So what's the difference between these two?


Solution

  • As we can see in ActionController::Base, before_action is just a new syntax for before_filter.

    However the before_filter syntax is deprecated in Rails 5.0 and will be removed in Rails 5.1