Raise an error if invalid value for database is provided.

This commit is contained in:
José Valim 2009-06-17 18:38:37 +02:00
parent 6619357f75
commit 090de591fc
2 changed files with 10 additions and 0 deletions

@ -7,6 +7,9 @@
module Rails
module Generators
class Error < Thor::Error
end
class Base < Thor::Group
include Rails::Generators::Actions
include Thor::Actions

@ -45,6 +45,13 @@ class App < Base
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 '.'