Your are here: Home // Posts Tagged With callbacks

ActiveRecord Observers

Podcast: Play in new window | Download About a month ago, I talked about ActiveRecord Callbacks. Observers are a way of moving callbacks out of the Model. Usually this is done to adhere to the Single Responsibility principle. So, for example, programmers will move sending an email when a record is updated or created to an Observer. class UserObserver < ActiveRecord::Observer def after_create(user) ... 

ActiveModel – Making Ruby Classes Behave Like Models

Podcast: Play in new window | Download I’ve been working on an ORM for Cassandra. One of the things I’ve been using to build the ORM is ActiveModel. ActiveModel gives you modules you can add to your class that makes it behave like an ActiveRecord Model. Here are some of the features you can add to your classes with ActiveModel. Attribute Methods Callbacks Dirty Attributes (knowing which attributes... 

ActiveRecord Callbacks

Podcast: Play in new window | Download You can get a full list of the ActiveRecord callbacks here. Callbacks are a handy way of insuring specific behaviors on your models as well as managing the events that follow the callbacks. For example, a before_destroy callback can be called to destroy associated objects. (This is best done on the association with :dependent => :destroy, but it makes... 
Copyright © 2009 Rails Coach. All rights reserved.
Designed by Theme Junkie. Powered by WordPress.