Class: HtmlBlocksGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- HtmlBlocksGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/html_blocks_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_views ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/generators/html_blocks_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
39 40 41 |
# File 'lib/generators/html_blocks_generator.rb', line 39 def add_controller template 'controller.rb', "app/controllers/#{plural_file_name}_controller.rb" if .ru? end |
#add_helper ⇒ Object
35 36 37 |
# File 'lib/generators/html_blocks_generator.rb', line 35 def add_helper template 'helper.rb', "app/helpers/#{plural_file_name}_helper.rb" end |
#add_migration ⇒ Object
21 22 23 |
# File 'lib/generators/html_blocks_generator.rb', line 21 def add_migration migration_template 'migration.rb', "db/migrate/create_#{table_name}" end |
#add_model ⇒ Object
17 18 19 |
# File 'lib/generators/html_blocks_generator.rb', line 17 def add_model template 'model.rb', "app/models/#{singular_table_name}.rb" end |
#add_route ⇒ Object
43 44 45 |
# File 'lib/generators/html_blocks_generator.rb', line 43 def add_route route "resources :#{plural_name}" end |
#add_views ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/html_blocks_generator.rb', line 25 def add_views if .playmo? && .ru? %w{_form new edit index}.each do |name| template "views-playmo-ru/#{name}.html.erb", "app/views/#{plural_file_name}/#{name}.html.erb" end gem "truncate_html" #copy_file 'gray.css', 'app/assets/stylesheets/basic/gray.css' end end |