Sha256: 5c1902cf57d709442953667901887196160eea2fdb853a5fda91bba989301608
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'rails/generators/rails/scaffold/scaffold_generator' require File.join(File.dirname(__FILE__), 'base') require File.join(File.dirname(__FILE__), 'scaffold_controller/scaffold_controller_generator') require File.join(File.dirname(__FILE__), 'active_record/active_record_generator') module NestedScaffold module Generators class NestedScaffoldGenerator < ::Rails::Generators::ScaffoldGenerator include ::NestedScaffold::Base # override ScaffoldGenerator hook_for :scaffold_controller, required: true # Ensure assets get created with the correct name hook_for :assets, in: :rails do |source, generator| source.invoke generator, [ source.file_name.pluralize ] end # override ModelGenerator hook_for :orm, required: true # replacing hook for adding config/routes remove_hook_for :resource_route # override def add_resource_route return if options[:actions].present? route_config = "resources :#{plural_nested_parent_name} do\n" route_config << " resources :#{file_name.pluralize}\n" route_config << " end" route route_config gsub_file 'config/routes.rb', / *resources :#{plural_nested_parent_name}\n/, '' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nested_scaffold-1.0.0 | lib/generators/nested_scaffold_generator.rb |