Skip to content

Commit

Permalink
Generate the cookies_serializer configuration with :marshal when upgr…
Browse files Browse the repository at this point in the history
…ading

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.
  • Loading branch information
rafaelfranca committed May 16, 2014
1 parent 779ff5c commit 8941d5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions railties/lib/rails/generators/rails/app/app_generator.rb
Expand Up @@ -86,6 +86,13 @@ def config
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
Expand Down Expand Up @@ -188,6 +195,10 @@ def create_config_files
build(:config)
end

def update_config_files
build(:config_when_updating)
end

def create_boot_file
template "config/boot.rb"
end
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/tasks/framework.rake
Expand Up @@ -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"
Expand Down

0 comments on commit 8941d5a

Please sign in to comment.