Sha256: 940684496e0bf29a13f12195481390bc26cdb1d16f616ab1a68c4e6f57ad1a0f
Contents?: true
Size: 961 Bytes
Versions: 21
Compression:
Stored size: 961 Bytes
Contents
require 'rails' module Alchemy module Generators class ModuleGenerator < ::Rails::Generators::Base desc "This generator generates an Alchemy module for you." argument :module_name, banner: "your_module_name" source_root File.expand_path('templates', File.dirname(__FILE__)) def init @module_name = module_name.downcase @class_name = @module_name.singularize.classify @controller_name = @module_name.tableize @controller_class = @controller_name.classify.pluralize end def make_route route "namespace :admin do\n resources :#{@controller_name}\n end" end def copy_templates template "controller.rb.tt", "app/controllers/admin/#{@controller_name}_controller.rb" template "ability.rb.tt", "app/models/#{@module_name}_ability.rb" template "module_config.rb.tt", "config/initializers/alchemy_#{@module_name}.rb" end end end end
Version data entries
21 entries across 21 versions & 1 rubygems