diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-03-05 21:18:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-05 21:18:00 +0900 |
commit | d13ce1f398216edac443fc45725049546d7e3865 (patch) | |
tree | 2a0cd34a190c3911326f8ee346606669aa02eaf8 /railties/lib | |
parent | ae2d36cf21281f4b720332a086b021d867e80084 (diff) | |
parent | e8be4f0891959afa1d6ca4510d1f9eb8e2887eb8 (diff) | |
download | rails-d13ce1f398216edac443fc45725049546d7e3865.tar.gz rails-d13ce1f398216edac443fc45725049546d7e3865.tar.bz2 rails-d13ce1f398216edac443fc45725049546d7e3865.zip |
Merge pull request #32170 from koic/deprecate_safe_level_of_erb_new_in_ruby_2_6
Deprecate safe_level of `ERB.new` in Ruby 2.6
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/migration.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb index 1cbccfe461..5081060895 100644 --- a/railties/lib/rails/generators/migration.rb +++ b/railties/lib/rails/generators/migration.rb @@ -63,7 +63,12 @@ module Rails numbered_destination = File.join(dir, ["%migration_number%", base].join("_")) create_migration numbered_destination, nil, config do - ERB.new(::File.binread(source), nil, "-", "@output_buffer").result(context) + match = ERB.version.match(/\Aerb\.rb \[(?<version>[^ ]+) /) + if match && match[:version] >= "2.2.0" # Ruby 2.6+ + ERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer").result(context) + else + ERB.new(::File.binread(source), nil, "-", "@output_buffer").result(context) + end end end end |