Created_on and updated_on in a non-ActiveRecord model

You are overwriting the 'save' method entirely, which overwrites the original behavior of save. The way ActiveRecord works the save method will check to see if you are saving a new record or updating an original, by calling "create_or_update".

If you are creating a new record the 'create' method is called. This method is actually aliased to 'create_with_callbacks', which invokes the callback stack for before_create, etc.

You can specify the callbacks you want to use in the following example:

def save(identifier)   if valid?      callback( :before_create )      # ... write to disk      callback( :after_create )   end   #... other stuff.... end

OR you can overwrite the create/callback chain:

class YourModel   def create       # YOUR CREATE FUNCTIONALITY HERE   end

  alias_method_chain :create, :callbacks end

Now when you call save, your "create" method will be used over ActiveRecord's. Now you don't even have to overrirde save, because you can put your "save" logic in the create method. Likewise you'd want to do the same for the "update" and "destroy" methods as well.

Zach http://www.continuousthinking.com