Is “proc” required with conditional before_action/before_filter?

Found it on Rails Guides: http://guides.rubyonrails.org/active_record_callbacks.html#conditional-callbacks

Turns out a Proc isn’t always required for it to work.

the :if and :unless options, which can take a symbol, a string, a Proc or an Array.

So in your case you could probably get away with

before_action :check_stuff, if: "Rails.env.production?"

Finding things in Rails documentation can be a pain sometimes, but at least questions like this make things easier to find over time since StackOverflow is well indexed and has high search rankings.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)