diff options
author | Carl Lerche <carllerche@mac.com> | 2010-02-01 13:43:17 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-02-01 13:43:17 -0800 |
commit | ff7a6a9b41937e8bc8e3259af09afe520a19c03e (patch) | |
tree | d00a9c22168a9fd47daecfccf3ab493a1d57d7c9 /railties/lib/generators/rails/app | |
parent | bf1f70d8776e28f9181faefc4914059b4ad26b99 (diff) | |
download | rails-ff7a6a9b41937e8bc8e3259af09afe520a19c03e.tar.gz rails-ff7a6a9b41937e8bc8e3259af09afe520a19c03e.tar.bz2 rails-ff7a6a9b41937e8bc8e3259af09afe520a19c03e.zip |
Add the database adapter in the generated Gemfile
Diffstat (limited to 'railties/lib/generators/rails/app')
-rw-r--r-- | railties/lib/generators/rails/app/app_generator.rb | 12 | ||||
-rw-r--r-- | railties/lib/generators/rails/app/templates/Gemfile | 8 |
2 files changed, 20 insertions, 0 deletions
diff --git a/railties/lib/generators/rails/app/app_generator.rb b/railties/lib/generators/rails/app/app_generator.rb index 2e34992b3b..918bb98db8 100644 --- a/railties/lib/generators/rails/app/app_generator.rb +++ b/railties/lib/generators/rails/app/app_generator.rb @@ -90,6 +90,18 @@ module Rails::Generators template "config/boot.rb" end + def gem_for_database + # %w( mysql oracle postgresql sqlite3 frontbase ibm_db ) + case options[:database] + when "mysql" then "mysql" + when "oracle" then "ruby-oci8" + when "postgresql" then "pg" + when "sqlite3" then "sqlite3-ruby" + when "frontbase" then "ruby-frontbase" + when "ibm_db" then "ibm_db" + end + end + def create_activerecord_files return if options[:skip_activerecord] template "config/databases/#{options[:database]}.yml", "config/database.yml" diff --git a/railties/lib/generators/rails/app/templates/Gemfile b/railties/lib/generators/rails/app/templates/Gemfile index 4db2b3e46c..50f1a6a414 100644 --- a/railties/lib/generators/rails/app/templates/Gemfile +++ b/railties/lib/generators/rails/app/templates/Gemfile @@ -13,6 +13,14 @@ gem "rails", "<%= Rails::VERSION::STRING %>" <%= "# " unless options.edge? %>gem "rails", :git => "git://github.com/rails/rails.git" <%- end -%> +<% unless options[:skip_activerecord] -%> +<% if options[:database] == 'sqlite3' -%> +# ActiveRecord requires a database adapter. By default, +# Rails has selected sqlite3. +<% end -%> +gem "<%= gem_for_database %>" +<% end -%> + ## Bundle the gems you use: # gem "bj" # gem "hpricot", "0.6" |