Class: MetaitemsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MetaitemsGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/metaitems_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_controller ⇒ Object
- #add_helper ⇒ Object
- #add_migration ⇒ Object
- #add_model ⇒ Object
- #add_route ⇒ Object
- #add_view ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/generators/metaitems_generator.rb', line 9 def self.next_migration_number(path) 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_controller ⇒ Object
34 35 36 |
# File 'lib/generators/metaitems_generator.rb', line 34 def add_controller template 'metaitems_controller.rb', 'app/controllers/metaitems_controller.rb' end |
#add_helper ⇒ Object
30 31 32 |
# File 'lib/generators/metaitems_generator.rb', line 30 def add_helper template 'metaitems_helper.rb', 'app/helpers/metaitems_helper.rb' end |
#add_migration ⇒ Object
21 22 23 |
# File 'lib/generators/metaitems_generator.rb', line 21 def add_migration migration_template 'migration.rb', 'db/migrate/create_metaitems' end |
#add_model ⇒ Object
17 18 19 |
# File 'lib/generators/metaitems_generator.rb', line 17 def add_model template 'metaitem.rb', 'app/models/metaitem.rb' end |
#add_route ⇒ Object
38 39 40 |
# File 'lib/generators/metaitems_generator.rb', line 38 def add_route route "resource :metaitem, :only => [:edit, :update]" end |
#add_view ⇒ Object
25 26 27 28 |
# File 'lib/generators/metaitems_generator.rb', line 25 def add_view source = .playmo? ? 'playmo' : 'default' template "views/#{source}.html.erb", 'app/views/metaitems/edit.html.erb' end |