cheat sheets.

$ cheat callbacks
--- callbacks version 3	Wed Oct 11 06:45:41 +0000 2006
+++ callbacks version 4	Tue Sep 23 22:48:41 +0000 2008
@@ -1,32 +1,58 @@
-Regular callbacks in ActiveRecord::Base
+Regular callbacks in ActiveRecord::Base:
 
   1. before_validation
   2. before_validation_on_create
   3. after_validation
   4. after_validation_on_create
   5. before_save
   6. before_create
   7. after_create
   8. after_save
   9. before_destroy
   10. after_destroy
 
-Usage
+Usage:
 
-  class Foo < ActiveRecord::Base
-    before_create :do_stuff
-  end
+  Define a method:
 
-Exceptions
+    class Foo < ActiveRecord::Base
+      def before_create
+        # your code here
+      end
+    end
 
-  * after_find
-  * after_initialize 
+ Invoke callback with a name of a method:
 
-Usage
+    class Foo < ActiveRecord::Base
+      before_create :do_stuff
+    protected
+      def do_stuff
+        # your code here
+      end
+    end
 
-  class Foo < ActiveRecord::Base
-    def after_find
-      do_stuff
+  Invoke callback with a block:
+
+    class Foo < ActiveRecord::Base
+      before_create do
+        def do_stuff
+          # your code here
+        end
+      end
     end
-  end
+
+Exceptions:
+
+  1. after_find
+  2. after_initialize 
+
+Usage:
+
+  Define a method:
+
+    class Foo < ActiveRecord::Base
+      def after_find
+        do_stuff
+      end
+    end
( add new | see all )