Forum: Ruby on Rails newbe: observer setup

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
David W. (Guest)
on 2006-02-20 01:57
(Received via mailing list)
Hi All,

Having problem setting up an observer to log changes to
a database.  I have following the Prag Rails book but think
I have something missing.  I am trying a simple puts to see
if the observer is working, but getting nothing on the console.

Here is what I have.  I don't get any errors.
Thanks for any suggestions/references to debugging.


The two models:


require 'observer'
class DisplayAd < ActiveRecord::Base
   include Observable
   has_many :activities
    #def after_update
     # puts "*************Updated display ad*************"


class DisplayAdObserver < ActiveRecord::Observer
   observe DisplayAd

   def after_save(display_ad) "Added display ad: #{}")
    puts "*************Saved display ad*************"

   def after_update(display_ad)
    puts "*************Updated display ad*************" "Updated display ad: #

And in environment.rb

  config.active_record.observers = :display_ad_observer
This topic is locked and can not be replied to.