Sha256: 72d8b783d84bbf6d3a54083359296601058e6da05873b70c6db7f0a4600b0297
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
require 'rails/generators/active_record/migration' class CmsGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) include Rails::Generators::Migration extend ActiveRecord::Generators::Migration class_option :except, type: :array, default: [], desc: 'skip certain types.' class_option :only, type: :string, default: false, desc: 'run a specific type generator.' class_option :migrate, type: :boolean, default: false, desc: 'generate the migration' class_option :controller, type: :boolean, default: false, desc: 'generate the controller' def create_migration_file if options[:only].present? migration_template 'migration.rb', "db/migrate/create_#{options[:only].underscore.pluralize}" if options[:migrate] else migration_template 'migration.rb', 'db/migrate/create_cms' if options[:migrate] end end def copy_controller_file template 'cms_base_controller.rb', 'app/controllers/cms/base_controller.rb' if options[:controller] empty_directory 'app/controllers/cms' empty_directory 'app/models/cms' CMS::Configuration.scoped_types(options).each do |type| @name = (@type = type).model_name template 'type_controller.rb', "app/controllers/cms/#{@name.collection}_controller.rb" template 'type_model.rb', "app/models/cms/#{@name.element}.rb" %w(index new show edit).each do |view| template "views/#{view}.html.haml", "app/views/cms/#{@name.collection}/#{view}.html.haml" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
honey-cms-0.1.2 | lib/generators/cms/cms_generator.rb |
honey-cms-0.1.1 | lib/generators/cms/cms_generator.rb |
honey-cms-0.1.0 | lib/generators/cms/cms_generator.rb |