aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorKyle Maxwell <kyle@kylemaxwell.com>2010-02-11 16:04:24 -0800
committerJosé Valim <jose.valim@gmail.com>2010-02-17 00:38:30 +0100
commitd4e008fd0f9ebac3383a0c3ac093de68db9e2e66 (patch)
tree768cc1c8a7f73699a834718dc3eb7b6712f19a34 /railties/lib
parent23fd1f12801c8585ff3b114e74264b67ad6264e9 (diff)
downloadrails-d4e008fd0f9ebac3383a0c3ac093de68db9e2e66.tar.gz
rails-d4e008fd0f9ebac3383a0c3ac093de68db9e2e66.tar.bz2
rails-d4e008fd0f9ebac3383a0c3ac093de68db9e2e66.zip
Invalid namespace on app generation raises an error
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/generators/rails/app/app_generator.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/railties/lib/generators/rails/app/app_generator.rb b/railties/lib/generators/rails/app/app_generator.rb
index c439ed89f5..ea1930a966 100644
--- a/railties/lib/generators/rails/app/app_generator.rb
+++ b/railties/lib/generators/rails/app/app_generator.rb
@@ -7,6 +7,10 @@ module Rails::Generators
# can change in Ruby 1.8.7 when we FileUtils.cd.
RAILS_DEV_PATH = File.expand_path("../../../../..", File.dirname(__FILE__))
+ RESERVED_NAMES = %w[generate console server dbconsole
+ application destroy benchmarker profiler
+ plugin runner test]
+
class AppGenerator < Base
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
@@ -209,9 +213,10 @@ module Rails::Generators
end
def valid_app_const?
- case app_const
- when /^\d/
+ if app_const =~ /^\d/
raise Error, "Invalid application name #{app_name}. Please give a name which does not start with numbers."
+ elsif RESERVED_NAMES.include?(app_name)
+ raise Error, "Invalid application name #{app_name}. Please give a name which does not match one of the reserved rails words."
end
end