Skip to content

Instantly share code, notes, and snippets.

@gstark
Created January 17, 2010 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gstark/279582 to your computer and use it in GitHub Desktop.
Save gstark/279582 to your computer and use it in GitHub Desktop.
in application.rb
config.active_record.observers = :foo_observer
foo_observer.rb:
class FooObserver < ActiveRecord::Observer
def before_update(foo)
end
end
foo.rb model:
class Foo < ActiveRecord::Base
include SomethingFromPlugin
end
This causes a 'uninitialized constant' for SomethingFromPlugin because the plugins aren't loaded yet.
rails/activerecord/lib/active_record/observer.rb:91 is causing the Foo model to load, through a chain of ActiveModel#observing => ActiveModel#observed_classes => ActiveModel#observed_class => constantize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment