From afc102698672cdf546a15424471d3287a39dbb06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 2 Jun 2010 08:45:03 +0200 Subject: Still copy application configuration to generator even if they are required earlier. Also tidy up the guide a little bit. --- railties/lib/rails/commands/destroy.rb | 1 + railties/lib/rails/commands/generate.rb | 1 + railties/lib/rails/generators.rb | 8 ++------ 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 9023c61bf2..db59cd8ad9 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,4 +1,5 @@ require 'rails/generators' +Rails::Generators.configure! if [nil, "-h", "--help"].include?(ARGV.first) Rails::Generators.help 'destroy' diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 7d05a30de8..1b3eef504a 100755 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,4 +1,5 @@ require 'rails/generators' +Rails::Generators.configure! if [nil, "-h", "--help"].include?(ARGV.first) Rails::Generators.help 'generate' diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index fe8a6c0b94..af92757053 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -68,6 +68,7 @@ module Rails options.deep_merge! config.options fallbacks.merge! config.fallbacks templates_path.concat config.templates + templates_path.uniq! end def self.templates_path @@ -328,10 +329,5 @@ module Rails paths.uniq! paths end - end -end - -# If the application was already defined, configure generators, -# otherwise you have to configure it by hand. -Rails::Generators.configure! if Rails.respond_to?(:application) && Rails.application +end \ No newline at end of file -- cgit v1.2.3 From 02512914ae547eb664a78c0f6084b121d5283a61 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 2 Jun 2010 16:17:05 -0500 Subject: You need the ruby-debug available in your Gemfile for debugger to work --- railties/lib/rails/generators/rails/app/templates/Gemfile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index f751c4519d..0b922a89c0 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -23,6 +23,9 @@ gem '<%= gem_for_database %>'<% if require_for_database %>, :require => '<%= req # Deploy with Capistrano # gem 'capistrano' +# To use debugger +# gem 'ruby-debug' + # Bundle the extra gems: # gem 'bj' # gem 'nokogiri', '1.4.1' -- cgit v1.2.3 From 4774680405adcbf0d3f64abbc236c7653d137fa3 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Thu, 3 Jun 2010 23:47:44 +1000 Subject: Changing command line API from 'rails blog' to 'rails new blog'. Also removed the limitation of not being able to call your new server any of the rails commands (generate, server, dbconsole, console etc) as there is no longer any ambiguity here. http://rails.lighthouseapp.com/projects/8994/tickets/4665 Signed-off-by: David Heinemeier Hansson --- railties/lib/rails/commands.rb | 6 ++++++ railties/lib/rails/commands/application.rb | 7 ++++++- railties/lib/rails/generators/rails/app/USAGE | 4 ++-- railties/lib/rails/generators/rails/app/app_generator.rb | 3 +-- 4 files changed, 15 insertions(+), 5 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index de93a87615..aad1170b56 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -38,6 +38,10 @@ when 'dbconsole' when 'application', 'runner' require "rails/commands/#{command}" +when 'new' + puts "Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.\n" + puts "Type 'rails' for help." + when '--version', '-v' ARGV.unshift '--version' require 'rails/commands/application' @@ -53,6 +57,8 @@ The most common rails commands are: server Start the Rails server (short-cut alias: "s") dbconsole Start a console for the database specified in config/database.yml (short-cut alias: "db") + new Create a new Rails application. "rails new my_app" creates a + new application called MyApp in "./my_app" In addition to those, there are: application Generate the Rails application code diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb index 8a8143e00e..a3a5aed399 100644 --- a/railties/lib/rails/commands/application.rb +++ b/railties/lib/rails/commands/application.rb @@ -4,7 +4,12 @@ if %w(--version -v).include? ARGV.first exit(0) end -ARGV << "--help" if ARGV.empty? +if ARGV.first != "new" || ARGV.empty? + ARGV[0] = "--help" +else + ARGV.shift +end + require 'rubygems' if ARGV.include?("--dev") require 'rails/generators' diff --git a/railties/lib/rails/generators/rails/app/USAGE b/railties/lib/rails/generators/rails/app/USAGE index 36d6061a59..9e7a78d132 100644 --- a/railties/lib/rails/generators/rails/app/USAGE +++ b/railties/lib/rails/generators/rails/app/USAGE @@ -1,9 +1,9 @@ Description: - The 'rails' command creates a new Rails application with a default + The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. Example: - rails ~/Code/Ruby/weblog + rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog. See the README in the newly created application to get going. diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index cd4a3dce4e..fc971907df 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -149,8 +149,7 @@ module Rails # can change in Ruby 1.8.7 when we FileUtils.cd. RAILS_DEV_PATH = File.expand_path("../../../../../..", File.dirname(__FILE__)) - RESERVED_NAMES = %w[generate g console c server s dbconsole db - application destroy benchmarker profiler + RESERVED_NAMES = %w[application destroy benchmarker profiler plugin runner test] class AppGenerator < Base -- cgit v1.2.3 From 6401ab587021b78c3dc5e4a5ac831823a9258481 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Fri, 4 Jun 2010 16:36:38 +1000 Subject: Missed fixing the banner on the Usage output for Thor Signed-off-by: David Heinemeier Hansson --- railties/lib/rails/generators/rails/app/app_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index fc971907df..7d50e7da67 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -309,7 +309,7 @@ module Rails protected def self.banner - "rails #{self.arguments.map(&:usage).join(' ')} [options]" + "rails new #{self.arguments.map(&:usage).join(' ')} [options]" end def builder -- cgit v1.2.3