Class: ActiveScaffold::Generators::ResourceGenerator

Inherits:
Rails::Generators::ResourceGenerator
  • Object
show all
Defined in:
lib/generators/active_scaffold/resource_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_resource_routeObject



43
44
45
46
47
48
49
50
51
# File 'lib/generators/active_scaffold/resource_generator.rb', line 43

def add_resource_route
  routing_code =  class_path.collect { |namespace| "namespace :#{namespace} do " }.join(' ')
  routing_code << "resources :#{file_name.pluralize}, concerns: :active_scaffold"
  routing_code << ' end' * class_path.size
  log :route, routing_code
  in_root do
    inject_into_file 'config/routes.rb', "  #{routing_code}\n", after: /^[ ]*concern :active_scaffold,.*\n/, verbose: false, force: true
  end
end