Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ActiveRecord::Observer.observed_classes doesn't get redefined properly #1034

Closed
lighthouse-import opened this Issue · 0 comments

1 participant

@lighthouse-import

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6715
Created by Grant Hutchins - 2011-04-18 18:20:28 UTC

class Foo < ActiveRecord::Base
end

class BarObserver < ActiveRecord::Observer
  observe :foo
end

ruby-1.8.7-p174 > BarObserver.observed_classes
NameError: uninitialized constant Bar
    from /Users/pivotal/.rvm/gems/ruby-1.8.7-p174/gems/activesupport-3.0.6/lib/active_support/inflector/methods.rb:113:in `constantize'
    from /Users/pivotal/.rvm/gems/ruby-1.8.7-p174/gems/activesupport-3.0.6/lib/active_support/inflector/methods.rb:112:in `each'
    from /Users/pivotal/.rvm/gems/ruby-1.8.7-p174/gems/activesupport-3.0.6/lib/active_support/inflector/methods.rb:112:in `constantize'
    from /Users/pivotal/.rvm/gems/ruby-1.8.7-p174/gems/activesupport-3.0.6/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
    from /Users/pivotal/.rvm/gems/ruby-1.8.7-p174/gems/activemodel-3.0.6/lib/active_model/observing.rb:182:in `observed_class'
    from /Users/pivotal/.rvm/gems/ruby-1.8.7-p174/gems/activemodel-3.0.6/lib/active_model/observing.rb:175:in `observed_classes'
    from (irb):1

By reading the implementation at https://github.com/rails/rails/blob/v3.0.6/activemodel/lib/active_model/observing.rb#L158-163 I would expect BarObserver's observed_classes method to have been redefined to return [Foo] without trying to find the non-existant Bar class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.