Class: Alchemy::Generators::ModuleGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/rails/generators/alchemy/module/module_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_templatesObject


21
22
23
24
25
# File 'lib/rails/generators/alchemy/module/module_generator.rb', line 21

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

#initObject


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_routeObject


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