mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
fix app generator
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6224 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -30,7 +30,7 @@ Rails::Initializer.run do |config|
|
||||
# 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
|
||||
|
||||
@@ -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 @@ class AppGenerator < Rails::Generator::Base
|
||||
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 @@ class AppGenerator < Rails::Generator::Base
|
||||
|
||||
# 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"
|
||||
|
||||
Reference in New Issue
Block a user