Sha256: 7d4c75bd002d4ce2c236841da1f39858fea5e4c0876192ec8e6e54516638498b

Contents?: true

Size: 538 Bytes

Versions: 44

Compression:

Stored size: 538 Bytes

Contents

require 'rails/generators/active_record'

module ScaffoldPlus
  module Generators
    class AutofocusGenerator < ActiveRecord::Generators::Base
      desc "Add autofocus to view"
      argument :name, type: :string,
               desc: "The object to be updated"
      argument :column, type: :string,
               desc: 'The column name to be focused'
      
      def add_to_view
        file = "app/views/#{table_name}/_form.html.erb"
        gsub_file file, /(:#{column}) %>/, "\\1, autofocus: true %>"
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
scaffold_plus-2.1.4 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-2.1.3 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-2.1.2 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-2.1.1 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.10.3 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.10.2 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.10.1 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.10.0 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.9.3 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.9.2 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.9.1 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.9.0 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.8.0 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.7.14 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.7.13 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.7.12 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.7.11 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.7.10 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.7.9 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
scaffold_plus-1.7.8 lib/generators/scaffold_plus/autofocus/autofocus_generator.rb