Class: Rails::Generators::ApiResourceRouteGenerator

Inherits:
ResourceRouteGenerator
  • Object
show all
Defined in:
lib/generators/rails/api_resource_route/api_resource_route_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_resource_routeObject


6
7
8
9
10
11
12
13
# File 'lib/generators/rails/api_resource_route/api_resource_route_generator.rb', line 6

def add_resource_route
  return if options[:actions].present?
  route_config =  regular_class_path.collect{ |namespace| "namespace :#{namespace} do " }.join(" ")
  route_config << "resources :#{file_name.pluralize}"
  route_config << ", except: [:new, :edit]"
  route_config << " end" * regular_class_path.size
  route route_config
end