How to use a callback into a concern

In Ruby on Rails < 3 (without Rails features, only Ruby) module MyModule def self.included(base) base.class_eval do before_save :something_to_do end end def something_to_do #whatever to do end end In Ruby on Rails >= 3 (with Rails Concern feature) module MyModule extend ActiveSupport::Concern included do before_save :something_to_do end def something_to_do #whatever to do end end    

HOW TO IMPLEMENT ACTS AS STATE MACHINE (AASM)

# DO IT INTO YOUR MODEL # INCLUDE include AASM # DECLARE ATTRIBUTE TO USE aasm.attribute_name :status # DECLARE WORKFLOW OF AASM aasm do state :[state_name], :initial => true state :[state_name], :initial => true, :before_enter => :[do_something] end