Sha256: 5dda0ce3c4d8005a075cc1836d5fec7eb48785db29b0caaac03478fc6339821c

Contents?: true

Size: 1.17 KB

Versions: 14

Compression:

Stored size: 1.17 KB

Contents

require 'rails/generators/resource_helpers'

module Rails
  module Generators
    class ScaffoldControllerGenerator < NamedBase # :nodoc:
      include ResourceHelpers

      check_class_collision suffix: "Controller"

      class_option :helper, type: :boolean
      class_option :orm, banner: "NAME", type: :string, required: true,
                         desc: "ORM to generate the controller for"
      class_option :api, type: :boolean,
                         desc: "Generates API controller"

      argument :attributes, type: :array, default: [], banner: "field:type field:type"

      def create_controller_files
        template_file = options.api? ? "api_controller.rb" : "controller.rb"
        template template_file, File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
      end


      hook_for :template_engine, as: :scaffold do |template_engine|
        invoke template_engine unless options.api?
      end

      hook_for :test_framework, as: :scaffold

      # Invoke the helper using the controller name (pluralized)
      hook_for :helper, as: :scaffold do |invoked|
        invoke invoked, [ controller_name ]
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
railties-5.0.7.2 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.7.1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.7 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.6 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.6.rc1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.5 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.5.rc2 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.5.rc1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.4 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.4.rc1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.3 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/railties-5.0.2/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.2 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.2.rc1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb