aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails_generator
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-02-25 18:41:13 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-02-25 18:41:13 +0000
commit290983be3114cd48f63265466abb57b15cbfb8f5 (patch)
tree7fb65ba475fab8bb2cd1200c6fa59f25eabb2357 /railties/lib/rails_generator
parent09993a60737aa642a47bd5047dd53f85a5c0120d (diff)
downloadrails-290983be3114cd48f63265466abb57b15cbfb8f5.tar.gz
rails-290983be3114cd48f63265466abb57b15cbfb8f5.tar.bz2
rails-290983be3114cd48f63265466abb57b15cbfb8f5.zip
Added -d/--database option to the rails command, so you can do "rails --database=sqlite2 myapp" to start a new application preconfigured to use SQLite2 as the database. Removed the configuration examples from SQLite and PostgreSQL from the default MySQL configuration [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3642 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/rails_generator')
-rw-r--r--railties/lib/rails_generator/generators/applications/app/app_generator.rb34
1 files changed, 18 insertions, 16 deletions
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 0818167fc4..2456f02451 100644
--- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb
+++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -4,16 +4,13 @@ class AppGenerator < Rails::Generator::Base
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
Config::CONFIG['ruby_install_name'])
- default_options :gem => true, :shebang => DEFAULT_SHEBANG
- mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
+ default_options :db => "mysql", :shebang => DEFAULT_SHEBANG
+ mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
def initialize(runtime_args, runtime_options = {})
super
usage if args.empty?
@destination_root = args.shift
- unless RUBY_PLATFORM =~ /mswin32/
- @socket = MYSQL_SOCKET_LOCATIONS.find { |f| File.exists?(f) }
- end
end
def manifest
@@ -35,9 +32,9 @@ class AppGenerator < Rails::Generator::Base
m.template "helpers/test_helper.rb", "test/test_helper.rb"
# database.yml and .htaccess
- m.template "configs/database.yml", "config/database.yml", :assigns => {
+ m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
:app_name => File.basename(File.expand_path(@destination_root)),
- :socket => @socket
+ :socket => options[:db] == "mysql" ? mysql_socket_location : nil
}
m.template "configs/routes.rb", "config/routes.rb"
m.template "configs/apache.conf", "public/.htaccess"
@@ -64,15 +61,15 @@ class AppGenerator < Rails::Generator::Base
m.template "html/#{file}.html", "public/#{file}.html"
end
- m.template "html/favicon.ico", "public/favicon.ico"
- m.template "html/robots.txt", "public/robots.txt"
+ m.template "html/favicon.ico", "public/favicon.ico"
+ m.template "html/robots.txt", "public/robots.txt"
m.file "html/images/rails.png", "public/images/rails.png"
# Javascripts
- m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
- m.file "html/javascripts/effects.js", "public/javascripts/effects.js"
- m.file "html/javascripts/dragdrop.js", "public/javascripts/dragdrop.js"
- m.file "html/javascripts/controls.js", "public/javascripts/controls.js"
+ m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
+ m.file "html/javascripts/effects.js", "public/javascripts/effects.js"
+ m.file "html/javascripts/dragdrop.js", "public/javascripts/dragdrop.js"
+ m.file "html/javascripts/controls.js", "public/javascripts/controls.js"
# Docs
m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
@@ -94,9 +91,14 @@ class AppGenerator < Rails::Generator::Base
opt.separator 'Options:'
opt.on("--ruby [#{DEFAULT_SHEBANG}]",
"Path to the Ruby binary of your choice.") { |options[:shebang]| }
- opt.on("--without-gems",
- "Don't use the Rails gems for your app.",
- "WARNING: see note below.") { |options[:gem]| }
+
+ opt.on("-d", "--database=name", String,
+ "Preconfigure for selected database (options: mysql/postgresql/sqlite2/sqlite3).",
+ "Default: mysql") { |options[:db]| }
+ end
+
+ def mysql_socket_location
+ RUBY_PLATFORM =~ /mswin32/ ? MYSQL_SOCKET_LOCATIONS.find { |f| File.exists?(f) } : nil
end