Class: AddressByCep::ModelGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/address_by_cep/model_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_js_in_application_js ⇒ Object
- #create_migration ⇒ Object
- #create_model ⇒ Object
- #create_partial ⇒ Object
-
#initialize(*args, &block) ⇒ ModelGenerator
constructor
A new instance of ModelGenerator.
Methods inherited from Base
Constructor Details
#initialize(*args, &block) ⇒ ModelGenerator
Returns a new instance of ModelGenerator.
7 8 9 |
# File 'lib/generators/address_by_cep/model_generator.rb', line 7 def initialize(*args, &block) super end |
Class Method Details
.next_migration_number(dirname) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/generators/address_by_cep/model_generator.rb', line 23 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#add_js_in_application_js ⇒ Object
15 16 17 |
# File 'lib/generators/address_by_cep/model_generator.rb', line 15 def add_js_in_application_js add_js_reference end |
#create_migration ⇒ Object
31 32 33 |
# File 'lib/generators/address_by_cep/model_generator.rb', line 31 def create_migration migration_template 'migration.rb', "db/migrate/create_table_addresses.rb" end |
#create_model ⇒ Object
19 20 21 |
# File 'lib/generators/address_by_cep/model_generator.rb', line 19 def create_model template 'address_model.rb', "app/models/address.rb" end |
#create_partial ⇒ Object
11 12 13 |
# File 'lib/generators/address_by_cep/model_generator.rb', line 11 def create_partial copy_file 'partial_addressable_form.html.erb', "app/views/addresses/_addressable_form.html.erb" end |