diff options
author | José Valim <jose.valim@gmail.com> | 2009-11-04 00:14:44 -0200 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-03 18:22:05 -0800 |
commit | d627c932bdc5c0e2911e39cfb38952c29dab7afc (patch) | |
tree | 16a2a6723f6a365d98c655e2b23574744ab6f7a3 /railties/lib/rails/generators | |
parent | e5211e3bd052ebc24905c65172d449f7b3bcc73f (diff) | |
download | rails-d627c932bdc5c0e2911e39cfb38952c29dab7afc.tar.gz rails-d627c932bdc5c0e2911e39cfb38952c29dab7afc.tar.bz2 rails-d627c932bdc5c0e2911e39cfb38952c29dab7afc.zip |
Pass config.generators options along when RAILS_GENERATORS is set and show --force-plural message just once.
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'railties/lib/rails/generators')
5 files changed, 15 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index c601c6fb39..8677bf283b 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -289,6 +289,7 @@ module Rails if args.size == 1 say args.first.to_s else + args << (self.behavior == :invoke ? :green : :red) say_status *args end end diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 0e5976f915..1d4f52286e 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -11,7 +11,10 @@ module Rails alias :file_name :singular_name - def initialize(*args) #:nodoc: + def initialize(args, *options) #:nodoc: + # Unfreeze name in case it's given as a frozen string + args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen? + super assign_names!(self.name) parse_attributes! if respond_to?(:attributes) diff --git a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt index c97090cdee..62a856d338 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt @@ -1,3 +1,4 @@ <%= shebang %> -require File.expand_path('../../config/application', __FILE__) +RAILS_GENERATORS = true +require File.expand_path('../../config/environment', __FILE__) require 'rails/commands/destroy' diff --git a/railties/lib/rails/generators/rails/app/templates/script/generate.tt b/railties/lib/rails/generators/rails/app/templates/script/generate.tt index 26f029c6a6..a005e77104 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/generate.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/generate.tt @@ -1,3 +1,4 @@ <%= shebang %> +RAILS_GENERATORS = true require File.expand_path('../../config/environment', __FILE__) require 'rails/commands/generate' diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index 0385581083..99954e2292 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -6,6 +6,8 @@ module Rails # ActiveModel. # module ResourceHelpers + mattr_accessor :skip_warn + def self.included(base) #:nodoc: base.send :attr_reader, :controller_name, :controller_class_name, :controller_file_name, :controller_class_path, :controller_file_path @@ -19,7 +21,11 @@ module Rails super if name == name.pluralize && !options[:force_plural] - say "Plural version of the model detected, using singularized version. Override with --force-plural." + unless ResourceHelpers.skip_warn + say "Plural version of the model detected, using singularized version. Override with --force-plural." + ResourceHelpers.skip_warn = true + end + name.replace name.singularize assign_names!(self.name) end |