diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-10-14 05:20:24 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-10-14 05:20:24 +0000 |
commit | f56dd107cdecb3cbffa04c320b4c30317331143d (patch) | |
tree | 0980293c4c75c61973e765066f07875603d0d743 | |
parent | a9eaa25a66eabb020eb9ce6c6de32681eacd9760 (diff) | |
download | rails-f56dd107cdecb3cbffa04c320b4c30317331143d.tar.gz rails-f56dd107cdecb3cbffa04c320b4c30317331143d.tar.bz2 rails-f56dd107cdecb3cbffa04c320b4c30317331143d.zip |
Observers can observe model names as symbols properly now. Closes #9869 [queso]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7872 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/observer.rb | 3 | ||||
-rwxr-xr-x | activerecord/test/lifecycle_test.rb | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 74226bb147..27c4168c63 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Observers can observe model names as symbols properly now. Closes #9869 [queso] + * find_and_(initialize|create)_by methods can now properly initialize protected attributes [Tobias Luetke] * belongs_to infers the foreign key from the association name instead of from the class name. [Jeremy Kemper] diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb index 9803155f2d..745ab96f0f 100644 --- a/activerecord/lib/active_record/observer.rb +++ b/activerecord/lib/active_record/observer.rb @@ -131,7 +131,8 @@ module ActiveRecord class << self # Attaches the observer to the supplied model classes. def observe(*models) - models.flatten.collect! { |model| model.is_a?(Symbol) ? model.to_s.camelize.constantize : model } + models.flatten! + models.collect! { |model| model.is_a?(Symbol) ? model.to_s.camelize.constantize : model } define_method(:observed_classes) { Set.new(models) } end diff --git a/activerecord/test/lifecycle_test.rb b/activerecord/test/lifecycle_test.rb index 2fdeb4181e..5f9e12a7e2 100755 --- a/activerecord/test/lifecycle_test.rb +++ b/activerecord/test/lifecycle_test.rb @@ -27,7 +27,7 @@ class TopicManualObserver end class TopicaObserver < ActiveRecord::Observer - def self.observed_class() Topic end + observe :topic attr_reader :topic |