Active Record Observers causing 404's and other weird issues

Hi all. I’ve got a simple AR Observer:

class NewOrderObserver < ActiveRecord::Observer

observe NewOrder

def after_create(object)
Note.create(…)
end

end

In environment.rb I have the following line:

config.active_record.observers = :new_order_observer

And in application.rb I have:

NewOrderObserver.instance

Aside from simply not working, it’s causing 404’s and telling me that
certain methods are suddenly no longer available. If I remove those
three bits of code, everything works fine.

Any ideas? Am I even doing things right? The documentation for observers
is so sparse.

Ah, nevermind. I’ve got it.

It was inside the Note.create that I was saying:

:notable_type => object.class

It should be:

:notable_type => object.class.to_s

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs