diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/observer.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb index 6e4db637f5..4e801a5843 100644 --- a/activerecord/lib/active_record/observer.rb +++ b/activerecord/lib/active_record/observer.rb @@ -151,10 +151,10 @@ module ActiveRecord end # The class observed by default is inferred from the observer's class name: - # assert_equal [Person], PersonObserver.observed_class + # assert_equal Person, PersonObserver.observed_class def observed_class - if observed_class_name = name.scan(/(.*)Observer/)[0] - observed_class_name[0].constantize + if observed_class_name = /(.*)Observer/.match(name)[1] + observed_class_name.constantize else nil end |