Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix app generator

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6224 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ad9bacb189e82816bf333cdbae329f199a171c9f 1 parent 08a5336
@technoweenie technoweenie authored
View
2  railties/environments/environment.rb
@@ -30,7 +30,7 @@
# If you change this key, all old sessions will become invalid!
config.action_controller.session = {
:session_key => '_<%= app_name %>_session',
- :secret => '<%= CGI::Session.generate_unique_id(app_name) %>'
+ :secret => '<%= app_secret %>'
}
# Use the database for sessions instead of the file system
View
14 railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -1,4 +1,5 @@
require 'rbconfig'
+require 'digest/md5'
class AppGenerator < Rails::Generator::Base
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
@@ -22,6 +23,15 @@ def manifest
script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
+ # duplicate CGI::Session#generate_unique_id
+ md5 = Digest::MD5.new
+ now = Time.now
+ md5 << now.to_s
+ md5 << String(now.usec)
+ md5 << String(rand(0))
+ md5 << String($$)
+ md5 << @app_name
+
record do |m|
# Root directory and all subdirectories.
m.directory ''
@@ -46,11 +56,11 @@ def manifest
# Initializers
m.template "configs/initializers/inflections.rb", "config/initializers/inflections.rb"
- m.template "configs/initializers/mime_types.rb", "configs/initializers/mime_types.rb"
+ m.template "configs/initializers/mime_types.rb", "config/initializers/mime_types.rb"
# Environments
m.file "environments/boot.rb", "config/boot.rb"
- m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] }
+ m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze], :app_name => @app_name, :app_secret => md5.hexdigest }
m.file "environments/production.rb", "config/environments/production.rb"
m.file "environments/development.rb", "config/environments/development.rb"
m.file "environments/test.rb", "config/environments/test.rb"
Please sign in to comment.
Something went wrong with that request. Please try again.