Permalink
Browse files

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...
1 parent ccecab3 commit f862376d169acfe362552787c095ff4b93834f9c @rafaelfranca rafaelfranca committed Nov 28, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 activerecord/lib/active_record/railtie.rb
@@ -115,6 +115,18 @@ class Railtie < Rails::Railtie # :nodoc:
See http://edgeguides.rubyonrails.org/security.html#mass-assignment for more information
EOF
end
+
+ unless app.config.active_record.delete(:observers).nil?
+ ActiveSupport::Deprecation.warn <<-EOF.strip_heredoc, []
+ Active Record Observers has been extracted out of Rails into a gem.
+ Please use callbaks or add `rails-observers` to your Gemfile to use observers.
+
+ To disable this message remove the `observers` option from your
+ `config/application.rb` or from your initializers.
+
+ See http://edgeguides.rubyonrails.org/4_0_release_notes.html for more information
+ EOF
+ end
ensure
ActiveSupport::Deprecation.behavior = old_behavior
end

0 comments on commit f862376

Please sign in to comment.