Tuesday, February 24, 2015

The around_* callback is called around the action and inside the before_* and after_* actions. For example:

class User
  def before_save
    puts 'before save'
  end

  def after_save
    puts 'after_save'
  end

  def around_save
    puts 'in around save'
    yield
    puts 'out around save'
  end
end

User.save
  before save
  in around save
  out around save
  after_save
=> true

No comments:

Post a Comment