Sha256: 3d0ba9ae1407600d258e60d87216a9ee77098d3ee5f88e6fdc3dcabd82e6df64

Contents?: true

Size: 1.06 KB

Versions: 21

Compression:

Stored size: 1.06 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, :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

21 entries across 21 versions & 3 rubygems

Version Path
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-5.0.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-5.0.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-5.0.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-5.0.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-5.0.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-5.0.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-5.0.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
abaci-0.3.0 vendor/bundle/gems/railties-5.0.0/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.1.rc2 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.1.rc1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0.1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0.rc2 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0.racecar1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0.rc1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0.beta4 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0.beta3 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0.beta2 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
railties-5.0.0.beta1.1 lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb