diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-01-22 11:43:22 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-01-22 11:44:31 +0900 |
commit | b8c34d1a09a5584497cbc9916ce2704288fe1420 (patch) | |
tree | 592bbc33320c90639f6c3f974e33c21ff4182b90 /activerecord/lib/rails | |
parent | fb5bd3c6f2f29c3ed370e82db0d3de52a97a0648 (diff) | |
download | rails-b8c34d1a09a5584497cbc9916ce2704288fe1420.tar.gz rails-b8c34d1a09a5584497cbc9916ce2704288fe1420.tar.bz2 rails-b8c34d1a09a5584497cbc9916ce2704288fe1420.zip |
move `db_migrate_path` method to `Migration` module
Since `Migration` module is included in both `MigrationGenerator` and
`ModelGenerator`, no need to define a common method for each class.
Diffstat (limited to 'activerecord/lib/rails')
3 files changed, 8 insertions, 16 deletions
diff --git a/activerecord/lib/rails/generators/active_record/migration.rb b/activerecord/lib/rails/generators/active_record/migration.rb index 4263c11ffc..43075077b9 100644 --- a/activerecord/lib/rails/generators/active_record/migration.rb +++ b/activerecord/lib/rails/generators/active_record/migration.rb @@ -20,6 +20,14 @@ module ActiveRecord key_type = options[:primary_key_type] ", id: :#{key_type}" if key_type end + + def db_migrate_path + if defined?(Rails) && Rails.application + Rails.application.config.paths["db/migrate"].to_ary.first + else + "db/migrate" + end + end end end end diff --git a/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb b/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb index c2ae21b4b2..1f1c47499b 100644 --- a/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb +++ b/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb @@ -71,14 +71,6 @@ module ActiveRecord def normalize_table_name(_table_name) pluralize_table_names? ? _table_name.pluralize : _table_name.singularize end - - def db_migrate_path - if defined?(Rails) && Rails.application - Rails.application.config.paths["db/migrate"].to_ary.first - else - "db/migrate" - end - end end end end 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 b26ad42859..5cec07d2e3 100644 --- a/activerecord/lib/rails/generators/active_record/model/model_generator.rb +++ b/activerecord/lib/rails/generators/active_record/model/model_generator.rb @@ -64,14 +64,6 @@ module ActiveRecord "app/models/application_record.rb" end end - - def db_migrate_path - if defined?(Rails) && Rails.application - Rails.application.config.paths["db/migrate"].to_ary.first - else - "db/migrate" - end - end end end end |