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
28
29
30
31
32
33
34
# 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 << <<-FILE.gsub(/^          /, '')
    resources :#{file_name.pluralize} do
        post :select,           :on => :collection
        post :edit_multiple,    :on => :collection
        put  :update_multiple,  :on => :collection
        put  :create_multiple,  :on => :collection
      end
  FILE
  route_config << " end" * (regular_class_path.size + plural_parent_resources.size + base_namespaces.size)
  route route_config
end