Class: Rails::Generators::LeoscaGenerator

Inherits:
ScaffoldGenerator
  • Object
show all
Includes:
Leonardo::Nested
Defined in:
lib/generators/rails/leosca/leosca_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_resource_routeObject

Override



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/rails/leosca/leosca_generator.rb', line 17

def add_resource_route
  return if options[:actions].present?

  route_config = ""
  route_config << plural_parent_resources.map{|m| "resources :#{m} do " }.join(" ") if nested?
  route_config << base_namespaces.map{|m| "namespace :#{m} do " }.join(" ") if leospaced?
  route_config << regular_class_path.map{|m| "namespace :#{m} do " }.join(" ")
  route_config << "resources :#{file_name.pluralize}"
  route_config << " end" * (regular_class_path.size + plural_parent_resources.size + base_namespaces.size)
  route route_config
end