# ActiveModel callbacks

**URL:** <https://www.ruby-forum.com/t/activemodel-callbacks/183141>\
**Category:** Rails\
**Created:** [February 8, 2010, 10:12pm UTC](https://www.ruby-forum.com/t/activemodel-callbacks/183141 "2010-02-08T22:12:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robkuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@robkuz](https://www.ruby-forum.com/u/robkuz)\
**Post date:** [February 8, 2010, 10:12pm UTC](https://www.ruby-forum.com/t/activemodel-callbacks/183141/1 "2010-02-08T22:12:59Z")

</div>

Hi,

I’ve set up several ActiveModel callbacks an run them via

\_run\_whatever\_callbacks do  
… some code  
end

Now i would like to run the before\_whatever and after\_whatever  
independently, aka  
\_run\_before\_whatever\_callbacks. Is that somehow possible?

I need that for running the callbacks on a set ob sub-objects, and i  
dont know how to nest the blocks dynamically (without any crazy hacks  
:-).

in short, I’d like to do something like that:

subobjects.each { |obj| obj.\_run\_before\_whatever\_callbacks }  
… some code  
subobjects.each { |obj| obj.\_run\_after\_whatever\_callbacks }

Thanks,  
Robert
