diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-03-07 13:26:03 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-03-07 13:26:03 -0300 |
commit | d3adfd6d3b6bb07f4e4d56b017eff1ff740523ff (patch) | |
tree | 03a5a3e4db0a4d51188a5114b1223179eb56c5ed /activerecord/lib | |
parent | cf09ac380e7d786d0d688983fb2080dc693f65a1 (diff) | |
parent | 53f18f2c5475809f7f6c5576aba89d6340a57c06 (diff) | |
download | rails-d3adfd6d3b6bb07f4e4d56b017eff1ff740523ff.tar.gz rails-d3adfd6d3b6bb07f4e4d56b017eff1ff740523ff.tar.bz2 rails-d3adfd6d3b6bb07f4e4d56b017eff1ff740523ff.zip |
Merge pull request #9474 from HonoreDB/master
More helpful error message when instantiating an abstract class
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/inheritance.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb index e630897a4b..13a8352f13 100644 --- a/activerecord/lib/active_record/inheritance.rb +++ b/activerecord/lib/active_record/inheritance.rb @@ -15,6 +15,9 @@ module ActiveRecord # and if the inheritance column is attr accessible, it initializes an # instance of the given subclass instead of the base class def new(*args, &block) + if abstract_class? || self == Base + raise NotImplementedError, "#{self} is an abstract class and can not be instantiated." + end if (attrs = args.first).is_a?(Hash) if subclass = subclass_from_attrs(attrs) return subclass.new(*args, &block) |