Sha256: 402e3034a7801a1efef41771e01e5a720c1872d75bbe312a2474a40cc08cc44e

Contents?: true

Size: 917 Bytes

Versions: 6

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

require "rails/generators/resource_helpers"
require_relative "controller_template_base"

module InertiaRailsContrib
  module Generators
    class ScaffoldTemplateBase < ControllerTemplateBase
      include Rails::Generators::ResourceHelpers

      remove_argument :actions

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

      def copy_view_files
        available_views.each do |view|
          filename = "#{view}.#{extension}"
          template "#{options.frontend_framework}/#{filename}", File.join(base_path, filename)
        end

        template "#{options.frontend_framework}/#{partial_name}.#{extension}", File.join(base_path, "#{inertia_component_name}.#{extension}")
      end

      private

      def available_views
        %w[Index Edit Show New Form]
      end

      def partial_name
        "One"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inertia_rails-contrib-0.3.0 lib/inertia_rails_contrib/generators/scaffold_template_base.rb
inertia_rails-contrib-0.2.2 lib/inertia_rails_contrib/generators/scaffold_template_base.rb
inertia_rails-contrib-0.2.1 lib/inertia_rails_contrib/generators/scaffold_template_base.rb
inertia_rails-contrib-0.2.0 lib/inertia_rails_contrib/generators/scaffold_template_base.rb
inertia_rails-contrib-0.1.1 lib/inertia_rails_contrib/generators/scaffold_template_base.rb
inertia_rails-contrib-0.1.0 lib/inertia_rails_contrib/generators/scaffold_template_base.rb