method

before_action

before_action
public

Append a callback before actions. See _insert_callbacks for parameter details.

1Note

Params of conditions

edivandecastro ยท Feb 3, 20161 thank

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 }