Skip to content

Instantly share code, notes, and snippets.

@awinabi
Created April 3, 2013 16:27
Show Gist options
  • Save awinabi/5302809 to your computer and use it in GitHub Desktop.
Save awinabi/5302809 to your computer and use it in GitHub Desktop.
ActiveRecord Callbacks correction
class Bill < ActiveRecord::Base
attr_accessible :name
before_validation :bvm
after_validation :avm
before_save :bsm
around_save :arsm
after_save :asm
before_create :bcm
around_create :arcm
after_create :acm
def bvm
p '...........before validation call back'
return true
end
def avm
p '...........after validation call back'
return true
end
def bsm
p '...........before save call back'
return true
end
def arsm
p '...........before yield - around save call back'
yield
p '...........after yield - around save call back'
return true
end
def bcm
p '...........before create call back'
return true
end
def arcm
p '...........before yield - around create call back'
yield
p '...........after yield - around create call back'
return true
end
def acm
p '...........after create call back'
return true
end
def asm
p '...........after save call back'
return true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment