From 8941d5a36fb06211eb4672fec1169372602232ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 16 May 2014 20:34:06 -0300 Subject: Generate the cookies_serializer configuration with :marshal when upgrading We were generating this configuration with :json what may break applications upgrating from Rails 4.0-. Now we always generate with a safer value and people is free to choose hybrid if they want. We don't generate with hybrid by default because there are some cases that can fail. These cases are explained on the upgrading guide. --- railties/lib/rails/generators/rails/app/app_generator.rb | 11 +++++++++++ railties/lib/rails/tasks/framework.rake | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 8675d8bc1e..e3a4a70e93 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -86,6 +86,13 @@ module Rails end end + def config_when_updating + foo = File.exist?('config/initializers/cookies_serializer.rb') + config + + gsub_file 'config/initializers/cookies_serializer.rb', /json/, 'marshal' unless foo + end + def database_yml template "config/databases/#{options[:database]}.yml", "config/database.yml" end @@ -188,6 +195,10 @@ module Rails build(:config) end + def update_config_files + build(:config_when_updating) + end + def create_boot_file template "config/boot.rb" end diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index 3c8f8c6b87..a1c805f8aa 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -55,7 +55,7 @@ namespace :rails do # desc "Update config/boot.rb from your current rails install" task :configs do invoke_from_app_generator :create_boot_file - invoke_from_app_generator :create_config_files + invoke_from_app_generator :update_config_files end # desc "Adds new executables to the application bin/ directory" -- cgit v1.2.3