class Pet
extend ActiveModel::Callbacks
define_model_callbacks :test
before_test :motherfucker
after_test do
puts "after that"
end
around_test do
puts 'around that'
end
def lala
puts "just a test"
# _run_test_callbacks do
# puts "real work"
# end
run_callbacks :test do
puts "real work"
end
run_callbacks :test do
puts "real work"
end
end
def motherfucker
puts "before that"
end
end
Pet.new.lala
class Pet
extend ActiveModel::Callbacks
define_model_callbacks :test
before_test :motherfucker
after_test do
puts "after that"
end
around_test do
puts 'around that'
end
skip_callback :test, :before, :motherfucker
def lala
puts "just a test"
# _run_test_callbacks do
# puts "real work"
# end
run_callbacks :test do
puts "real work"
end
run_callbacks :test do
puts "real work"
end
end
def motherfucker
puts "before that"
end
end
Pet.new.lala
但是好像skip_callback不能用于proc block
http://stackoverflow.com/questions/19021465/skip-before-filter-defined-with-block