« Book Ecosystems | Main | Annotate Models Plugin »

February 21, 2006

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83451c41c69e200d83572a02569e2

Listed below are links to weblogs that reference Logging Changes when Saving ActiveRecord Objects:

Comments

Yonatan Feldman

I have a similar situation where I am keeping track of changes to an AR object by overriding the attribute= methods for the attributes I am interested in tracking. I then use an after_update callback to log the changes.

One of the attributes I am tracking is actually an association (:users) and I keep track of who is assigned or unassigned from the object.

This worked fine when I was using a HABTM association but now that I am moving to a has_many :through I can't call 'object.users <<' before object has been saved. I can work around this by not using the after_update :log_changes and instead call it after I assign users to the object but this seems pretty ugly.

Is there a better way to do this?

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Now in Beta

  • Programming Ruby, 3rd Edition
    Third Edition, Covering Ruby 1.9, now available
My Photo

Pragmatic Stuff

Photos

  • www.flickr.com
    This is a Flickr badge showing public photos from pragdave tagged with pragdave_badge. Make your own badge here.

Site Search

  • Google Search

    The web
    PragDave