From 9b84567fd438acf0e4a973e2be46dce3ba5c6ea0 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 7 Mar 2017 10:16:49 +0000 Subject: Check whether `Rails.application` defined before calling it In #27674 we changed the migration generator to generate migrations at the path defined in `Rails.application.config.paths` however the code checked for the presence of the `Rails` constant but not the `Rails.application` method which caused problems when using Active Record and generators outside of the context of a Rails application. Fixes #28325. --- activerecord/CHANGELOG.md | 10 ++++++++++ activerecord/lib/rails/generators/active_record/migration.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index b2c57e792f..e00a62b8cd 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,13 @@ +* Check whether `Rails.application` defined before calling it + + In #27674 we changed the migration generator to generate migrations at the + path defined in `Rails.application.config.paths` however the code checked + for the presence of the `Rails` constant but not the `Rails.application` + method which caused problems when using Active Record and generators outside + of the context of a Rails application. + + Fixes #28325. + * Fix `deserialize` with JSON array. Fixes #28285. diff --git a/activerecord/lib/rails/generators/active_record/migration.rb b/activerecord/lib/rails/generators/active_record/migration.rb index 43075077b9..47c0981a49 100644 --- a/activerecord/lib/rails/generators/active_record/migration.rb +++ b/activerecord/lib/rails/generators/active_record/migration.rb @@ -22,7 +22,7 @@ module ActiveRecord end def db_migrate_path - if defined?(Rails) && Rails.application + if defined?(Rails.application) && Rails.application Rails.application.config.paths["db/migrate"].to_ary.first else "db/migrate" -- cgit v1.2.3