Skip to content
This repository
Browse code

Gracefully handle upgrading apps with observers

Rather than just raising a NoMethodError when copying the config, this
commit adds a warning message until either the rails-observers gem is
installed or the relevant config options are removed.
  • Loading branch information...
commit f862376d169acfe362552787c095ff4b93834f9c 1 parent ccecab3
Rafael Mendonça França authored November 28, 2012

Showing 1 changed file with 12 additions and 0 deletions. Show diff stats Hide diff stats

  1. 12  activerecord/lib/active_record/railtie.rb
12  activerecord/lib/active_record/railtie.rb
@@ -115,6 +115,18 @@ class Railtie < Rails::Railtie # :nodoc:
115 115
               See http://edgeguides.rubyonrails.org/security.html#mass-assignment for more information
116 116
             EOF
117 117
           end
  118
+
  119
+          unless app.config.active_record.delete(:observers).nil?
  120
+            ActiveSupport::Deprecation.warn <<-EOF.strip_heredoc, []
  121
+              Active Record Observers has been extracted out of Rails into a gem.
  122
+              Please use callbaks or add `rails-observers` to your Gemfile to use observers.
  123
+
  124
+              To disable this message remove the `observers` option from your
  125
+              `config/application.rb` or from your initializers.
  126
+
  127
+              See http://edgeguides.rubyonrails.org/4_0_release_notes.html for more information
  128
+            EOF
  129
+          end
118 130
         ensure
119 131
           ActiveSupport::Deprecation.behavior = old_behavior
120 132
         end

0 notes on commit f862376

Please sign in to comment.
Something went wrong with that request. Please try again.