method
before_action
v4.2.1 -
Show latest stable
- Class:
AbstractController::Callbacks::ClassMethods
before_actionpublic
Append a callback before actions. See _insert_callbacks for parameter details.
1Note
Params of conditions
You can pass an proc for o callback with the conditions
before_action :initial_value, only: [:index, :show], unless: -> { @foo.nil? }
before_action :initial_value, only: [:index, :show], if: -> { @foo }