aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/rails/generators
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2015-12-16 14:37:57 -0200
committerRafael França <rafaelmfranca@gmail.com>2015-12-16 14:37:57 -0200
commit1d7d8062b2576f835f5475e4adad0bb79e53f8ad (patch)
tree87bbbc5278ccb4ea69b2cf1bb21dbfab203abc52 /activerecord/lib/rails/generators
parent371e357065edf362144af7f44b7ff0755d1b0165 (diff)
parent2067fff9e38df4e37bdbfc021cd6bb0c2d393a2a (diff)
downloadrails-1d7d8062b2576f835f5475e4adad0bb79e53f8ad.tar.gz
rails-1d7d8062b2576f835f5475e4adad0bb79e53f8ad.tar.bz2
rails-1d7d8062b2576f835f5475e4adad0bb79e53f8ad.zip
Merge pull request #22567 from gsamokovarov/introduce-application-record
Introduce ApplicationRecord, an Active Record layer supertype
Diffstat (limited to 'activerecord/lib/rails/generators')
-rw-r--r--activerecord/lib/rails/generators/active_record/model/model_generator.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/model_generator.rb b/activerecord/lib/rails/generators/active_record/model/model_generator.rb
index 395951ac9d..e4c9539362 100644
--- a/activerecord/lib/rails/generators/active_record/model/model_generator.rb
+++ b/activerecord/lib/rails/generators/active_record/model/model_generator.rb
@@ -43,9 +43,16 @@ module ActiveRecord
# Used by the migration template to determine the parent name of the model
def parent_class_name
- options[:parent] || "ActiveRecord::Base"
+ options[:parent] || determine_default_parent_class
end
+ def determine_default_parent_class
+ if File.exist?('app/models/application_record.rb')
+ "ApplicationRecord"
+ else
+ "ActiveRecord::Base"
+ end
+ end
end
end
end