From 0adcd811f945603a8037febaa158bbc1ffaba9d1 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 7 May 2006 08:28:42 +0000 Subject: [PATCH] The app generator sets a session key in application.rb so apps running on the same host may distinguish their cookies. Closes #2967. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4328 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/CHANGELOG | 2 ++ railties/helpers/application.rb | 10 ++++++++-- .../generators/applications/app/app_generator.rb | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 64df785995..c79e1dcc97 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* The app generator sets a session key in application.rb so apps running on the same host may distinguish their cookies. #2967 [rcoder, rails-bug@owl.me.uk] + * Distinguish the spawners for different processes [DHH] * Added -n/--process to script/process/spawner name the process pid (default is dispatch) [DHH] diff --git a/railties/helpers/application.rb b/railties/helpers/application.rb index 537de40d7e..99e4b0d1cf 100644 --- a/railties/helpers/application.rb +++ b/railties/helpers/application.rb @@ -1,4 +1,10 @@ -# Filters added to this controller will be run for all controllers in the application. +# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. + class ApplicationController < ActionController::Base -end \ No newline at end of file + # Pick a unique cookie name to distinguish our session data from others'. + session :session_key => '_<%= app_name %>_session_id' + + # Or disable sessions entirely. + #session :off +end diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index a61331b5b3..44386f7ac2 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -14,6 +14,7 @@ def initialize(runtime_args, runtime_options = {}) usage if args.empty? usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if (options[:db] && !DATABASES.include?(options[:db])) @destination_root = args.shift + @app_name = File.basename(File.expand_path(@destination_root)) end def manifest @@ -31,13 +32,13 @@ def manifest m.file "README", "README" # Application - m.template "helpers/application.rb", "app/controllers/application.rb" + m.template "helpers/application.rb", "app/controllers/application.rb", :assigns => { :app_name => @app_name } m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb" m.template "helpers/test_helper.rb", "test/test_helper.rb" # database.yml and .htaccess m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => { - :app_name => File.basename(File.expand_path(@destination_root)), + :app_name => @app_name, :socket => options[:db] == "mysql" ? mysql_socket_location : nil } m.template "configs/routes.rb", "config/routes.rb" -- GitLab