Rails has a lovely feature as part of ActiveRecord - Callbacks; to wit: Callbacks are hooks into the life cycle of an Active Record object that allow you to trigger logic before or after an alteration of the object state Basically, that means that you can instruct Rails to execute your own code throughout the process of creating, updating and destroying objects/records. You can, for example, use them to set some default values on create, or perhaps do some last minute validation, or even fire an event just after you've saved a record. The available callbacks are: after_initialize after_find after_touch before_validation after_validation before_save around_save after_save before_create around_create after_create before_update around_update after_update :before_destroy around_destroy after_destroy after_commit after_rollback At the same time, Ruby methods have the concept of implicit return values. That is to say, any method will return the value of the la...
snippets and tidbits about Ruby, Rails, Sinatra and anything else web-dev like