Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Observers and Rails 2.3.5

#3850

Hello there guys,
i'm facing a strange problem using Observers with Rails 2.3.5.

1) I generated a new observer using builtin generator
2) I added observer into environment.rb (config.active_record.observers = [:project])

Observer content
class ProjectObserver < ActiveRecord::Observer
def after_create(project)

#

end end

Rails 2.3.5 crashes at startup, with following message
=> Booting Mongrel => Rails 2.3.5 application starting on http://0.0.0.0:3000 /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:in method_missing': undefined methodinstance' for #<Class:0x1034416d8> (NoMethodError)

from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:38:in `instantiate_observers'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:36:in `each'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:36:in `instantiate_observers'
from /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:15:in `define_dispatcher_callbacks'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in `call'

[...]

Rails 2.3.4 boots without problems.

How can i help you to get this fixed?
Need other informations?

Thanks.

Reported by sad sheep · February 4th, 2010 @ 03:55 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Matt Jones
    Matt Jones

    Not sure how this was working in 2.3.4, but your syntax is incorrect: :project in config.active_record.observers should be :project_observer.

    February 4th, 2010 @ 09:05 PM

  2. sad sheep
    sad sheep

    Sorry for my mistake :(

    Rails 2.3.5 works with your syntax.

    I suggest to change into environment.rb the following commented lines then:

    Activate observers that should always be running

    config.active_record.observers = :cacher, :garbage_collector, :forum_observer

    Thanks and keep up the good work!

    m.

    February 5th, 2010 @ 08:46 AM

  3. Matt Jones
    Matt Jones
    • State changed from new to invalid

    I'm unsure what your comment above is supposed to mean - there's no magic applied to the names of the observers, so what you put in the config statement is what you get.

    Closing for now.

    February 7th, 2010 @ 09:36 PM

  4. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:44 PM