Class: ModelMill::Generators::ModelsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ModelMill::Generators::ModelsGenerator
- Defined in:
- lib/generators/model_mill/models/models_generator.rb
Instance Method Summary collapse
-
#generate_models ⇒ Object
argument :excludes, :type => :array, :required => false, :default => [].
Instance Method Details
#generate_models ⇒ Object
argument :excludes, :type => :array, :required => false, :default => []
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/model_mill/models/models_generator.rb', line 9 def generate_models if [:namespace] empty_directory("app/models/#{[:namespace].downcase}") generate_base_namespaced_model end discovered_tables.each do |table_name| @model_name = model_name_from_table_name table_name @model_file_name = model_file_name_from_table_name table_name @columns = connection.columns(table_name) @indexes = connection.indexes(table_name) @associations = detected_associations(table_name, @columns) template 'model.rb', "app/models/#{[:namespace] ? [:namespace]+'/' : ''}#{@model_file_name}.rb" end puts %Q(config.autoload_paths += %W(\#{config.root}/app/models/#{[:namespace].downcase})) if [:namespace] end |