Class: RecursWidgetGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RecursWidgetGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/recurs_widget_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_instance_controller ⇒ Object
- #create_instance_model ⇒ Object
- #create_instance_route ⇒ Object
- #create_instance_views ⇒ Object
- #create_migration_file ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
33 34 35 |
# File 'lib/generators/recurs_widget_generator.rb', line 33 def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#create_instance_controller ⇒ Object
29 30 31 |
# File 'lib/generators/recurs_widget_generator.rb', line 29 def create_instance_controller template "controller.rb.tmpl", "app/controllers/#{name.downcase}s_controller.rb" end |
#create_instance_model ⇒ Object
11 12 13 14 |
# File 'lib/generators/recurs_widget_generator.rb', line 11 def create_instance_model template "instance.rb.tmpl", "app/models/#{name.downcase}.rb" #create_file "app/models#{model_name}" end |
#create_instance_route ⇒ Object
25 26 27 |
# File 'lib/generators/recurs_widget_generator.rb', line 25 def create_instance_route insert_into_file 'config/routes.rb', "resources :#{name.downcase}s", :after => "Application.routes.draw do\n" end |
#create_instance_views ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/generators/recurs_widget_generator.rb', line 16 def create_instance_views ['index', 'show', 'edit', 'new', '_form'].each {|v| template "views/#{v}", "app/views/#{name.downcase}s/#{v}.html.haml" } ['_monthly', '_set_points', '_standard', '_weekly'].each {|v| template "views/schemes/#{v}", "app/views/#{name.downcase}s/schemes/#{v}.html.haml" } end |
#create_migration_file ⇒ Object
37 38 39 |
# File 'lib/generators/recurs_widget_generator.rb', line 37 def create_migration_file migration_template 'migration.rb.tmpl', "db/migrate/create_#{name.downcase}s.rb" end |