Class: Alchemy::Generators::ModuleGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Alchemy::Generators::ModuleGenerator
- Defined in:
- lib/rails/generators/alchemy/module/module_generator.rb
Instance Method Summary collapse
Instance Method Details
#copy_templates ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rails/generators/alchemy/module/module_generator.rb', line 21 def copy_templates empty_directory Rails.root.join("app/controllers/admin") template "controller.rb.tt", Rails.root.join("app/controllers/admin/#{@controller_name}_controller.rb") template "ability.rb.tt", Rails.root.join('app/models', "alchemy_#{@module_name}_ability.rb") template "module_config.rb.tt", Rails.root.join("config/initializers/alchemy_#{@module_name}.rb") end |
#init ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rails/generators/alchemy/module/module_generator.rb', line 10 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 |
#make_route ⇒ Object
17 18 19 |
# File 'lib/rails/generators/alchemy/module/module_generator.rb', line 17 def make_route route "namespace :admin do\n resources :#{@controller_name}\n end" end |