module Scrivito module Generators class PageGenerator < ::Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) argument :name, type: :string argument :attributes, type: :array, default: [], banner: 'attribute:type attribute:type' def create_model template 'model.erb', "app/models/#{file_name}.rb" end def create_controller template 'controller.erb', "app/controllers/#{file_name}_controller.rb" end def create_views copy_file 'index.html.erb', "app/views/#{file_name}/index.html.erb" copy_file 'details.html.erb', "app/views/#{file_name}/details.html.erb" template 'thumbnail.html.erb', "app/views/#{file_name}/thumbnail.html.erb" end end end end