ruby-on-railsruby-on-rails-5actioncontroller

What is the behaviour when an array is passed to an if condition of a callback in a Rails controller


I saw a callback in a controller that looks something like this:

 before_action :do_stuff, if: [:condition_1?, :condition_2?], only: :show

What will be the behaviour of the if condition in this case? The Rails documentation only specifies passing a symbol or a Proc.


Solution

  • If both conditions return true or values other than false and nil then do_stuff method will be invoked but only for show action