Skip to content
This repository
Browse code

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
risk danger olson authored February 24, 2007
2  railties/environments/environment.rb
@@ -30,7 +30,7 @@
30 30
   # If you change this key, all old sessions will become invalid!
31 31
   config.action_controller.session = {
32 32
     :session_key => '_<%= app_name %>_session',
33  
-    :secret      => '<%= CGI::Session.generate_unique_id(app_name) %>'
  33
+    :secret      => '<%= app_secret %>'
34 34
   }
35 35
 
36 36
   # Use the database for sessions instead of the file system
14  railties/lib/rails_generator/generators/applications/app/app_generator.rb
... ...
@@ -1,4 +1,5 @@
1 1
 require 'rbconfig'
  2
+require 'digest/md5' 
2 3
 
3 4
 class AppGenerator < Rails::Generator::Base
4 5
   DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
@@ -22,6 +23,15 @@ def manifest
22 23
     script_options     = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
23 24
     dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
24 25
 
  26
+    # duplicate CGI::Session#generate_unique_id
  27
+    md5 = Digest::MD5.new
  28
+    now = Time.now
  29
+    md5 << now.to_s
  30
+    md5 << String(now.usec)
  31
+    md5 << String(rand(0))
  32
+    md5 << String($$)
  33
+    md5 << @app_name
  34
+
25 35
     record do |m|
26 36
       # Root directory and all subdirectories.
27 37
       m.directory ''
@@ -46,11 +56,11 @@ def manifest
46 56
 
47 57
       # Initializers
48 58
       m.template "configs/initializers/inflections.rb", "config/initializers/inflections.rb"
49  
-      m.template "configs/initializers/mime_types.rb",  "configs/initializers/mime_types.rb"
  59
+      m.template "configs/initializers/mime_types.rb",  "config/initializers/mime_types.rb"
50 60
 
51 61
       # Environments
52 62
       m.file "environments/boot.rb",    "config/boot.rb"
53  
-      m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] }
  63
+      m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze], :app_name => @app_name, :app_secret => md5.hexdigest }
54 64
       m.file "environments/production.rb",  "config/environments/production.rb"
55 65
       m.file "environments/development.rb", "config/environments/development.rb"
56 66
       m.file "environments/test.rb",        "config/environments/test.rb"

0 notes on commit ad9bacb

Please sign in to comment.
Something went wrong with that request. Please try again.