Sha256: 30c6372db585be68a7bdcef7b2227eb49f6f568841fb2de9c396ce67cfe63c69

Contents?: true

Size: 1.55 KB

Versions: 76

Compression:

Stored size: 1.55 KB

Contents

module BulletTrain
  module SuperScaffolding
    module Scaffolders
      class CrudFieldScaffolder < Scaffolder
        def run
          unless argv.count >= 2
            puts ""
            puts "🚅  usage: bin/super-scaffold crud-field <Model> <attribute:type> <attribute:type> ... [options]"
            puts ""
            puts "E.g. add a description and body to Pages:"
            puts "  rails g migration add_description_etc_to_pages description:text body:text"
            puts "  bin/super-scaffold crud-field Page description:text_area body:text_area"
            puts ""
            puts "Options:"
            puts ""
            puts "  --skip-table: Only add to the new/edit form and show view."
            puts ""
            exit
          end

          # We pass this value to parents to create a new Scaffolding::Transformer because
          # we don't actually need knowledge of the parent to add the new field.
          parents = [""]
          child = argv[0]

          # get all the attributes.
          attributes = argv[1..]

          check_required_options_for_attributes("crud-field", attributes, child)

          transformer = Scaffolding::Transformer.new(child, parents, @options)
          transformer.add_attributes_to_various_views(attributes, type: :crud_field)

          transformer.additional_steps.uniq.each_with_index do |additional_step, index|
            color, message = additional_step
            puts ""
            puts "#{index + 1}. #{message}".send(color)
          end
          puts ""
        end
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
bullet_train-super_scaffolding-1.6.6 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.6.5 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.6.4 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.6.3 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.6.2 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.6.1 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.6.0 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.5.2 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.5.1 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.5.0 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.11 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.10 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.9 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.8 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.7 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.6 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.5 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.4 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.3 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb
bullet_train-super_scaffolding-1.4.2 lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb