Class: Rails::ModelsGenerator
- Inherits:
-
ActiveRecord::Generators::ModelGenerator
- Object
- ActiveRecord::Generators::ModelGenerator
- Rails::ModelsGenerator
- Defined in:
- lib/generators/rails/models_generator.rb
Instance Method Summary collapse
-
#create_migration_file ⇒ Object
don’t create migration file.
- #create_model_file ⇒ Object
-
#initialize(args, *options) ⇒ ModelsGenerator
constructor
A new instance of ModelsGenerator.
Constructor Details
#initialize(args, *options) ⇒ ModelsGenerator
Returns a new instance of ModelsGenerator.
11 12 13 14 |
# File 'lib/generators/rails/models_generator.rb', line 11 def initialize(args, *) self.name = args.pop || 'base' super end |
Instance Method Details
#create_migration_file ⇒ Object
don’t create migration file
17 |
# File 'lib/generators/rails/models_generator.rb', line 17 def create_migration_file; end |
#create_model_file ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/rails/models_generator.rb', line 19 def create_model_file tables = ActiveRecord::Base.connection.tables - [ActiveRecord::Migrator.schema_migrations_table_name] tables.each do |tbl_name| clear_instance_variables pluralize_table_names? ? tbl_name.singularize : tbl_name template 'model.rb.erb', File.join('app/models', class_path, "#{file_name}.rb") template 'model_spec.rb.erb', File.join('spec/models', class_path, "#{file_name}_spec.rb") template 'fabricator.rb.erb', File.join('spec/fabricators', class_path, "#{file_name}_fabricator.rb") end end |