From 090de591fc9038e12a94aa109829919ccec3a0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 17 Jun 2009 18:38:37 +0200 Subject: Raise an error if invalid value for database is provided. --- railties/lib/generator/base.rb | 3 +++ railties/lib/generator/generators/app.rb | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'railties/lib/generator') diff --git a/railties/lib/generator/base.rb b/railties/lib/generator/base.rb index 5f51f93520..604e705e73 100644 --- a/railties/lib/generator/base.rb +++ b/railties/lib/generator/base.rb @@ -7,6 +7,9 @@ require 'thor' module Rails module Generators + class Error < Thor::Error + end + class Base < Thor::Group include Rails::Generators::Actions include Thor::Actions diff --git a/railties/lib/generator/generators/app.rb b/railties/lib/generator/generators/app.rb index c775d0da12..8b22437db6 100644 --- a/railties/lib/generator/generators/app.rb +++ b/railties/lib/generator/generators/app.rb @@ -45,6 +45,13 @@ module Rails::Generators class_option :help, :type => :boolean, :aliases => "-h", :group => :rails, :desc => "Show this help message and quit" + def initialize(*args) + super + if !options[:no_activerecord] && !DATABASES.include?(options[:database]) + raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}." + end + end + def create_root self.root = File.expand_path(app_path, root) empty_directory '.' -- cgit v1.2.3