1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Andrew White 2017-03-07 10:16:49 +00:00
parent 7716b6ed22
commit 9b84567fd4
2 changed files with 11 additions and 1 deletions

View file

@ -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.

View file

@ -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"