Class: Forest::BlockGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Forest::BlockGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/forest/block/block_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_migration_file ⇒ Object
- #create_model_file ⇒ Object
- #create_stylesheet ⇒ Object
- #create_view_files ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
8 9 10 11 |
# File 'lib/generators/forest/block/block_generator.rb', line 8 def self.next_migration_number(dirname) next_migration_number = current_migration_number(dirname) + 1 ActiveRecord::Migration.next_migration_number(next_migration_number) end |
Instance Method Details
#create_migration_file ⇒ Object
22 23 24 25 26 |
# File 'lib/generators/forest/block/block_generator.rb', line 22 def create_migration_file set_local_assigns! validate_file_name! migration_template 'create_table_migration.rb', "db/migrate/create_#{table_name}.rb" end |
#create_model_file ⇒ Object
13 14 15 |
# File 'lib/generators/forest/block/block_generator.rb', line 13 def create_model_file template 'model.rb', File.join('app/models/blocks', "#{file_name}.rb") end |
#create_stylesheet ⇒ Object
28 29 30 |
# File 'lib/generators/forest/block/block_generator.rb', line 28 def create_stylesheet template '_block.scss.erb', File.join('app/assets/stylesheets/blocks', "_#{file_name}.scss") end |
#create_view_files ⇒ Object
17 18 19 20 |
# File 'lib/generators/forest/block/block_generator.rb', line 17 def create_view_files template "_block.html.erb", File.join('app/views/blocks', file_name, "_show.html.erb") template "_block_edit_fields.html.erb", File.join('app/views/blocks', file_name, "_edit.html.erb") end |