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
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

#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