Sha256: 208c8677b4a663a98cc77b127a40bc2b4e87422da6240bc1cf0d4703882baa2d

Contents?: true

Size: 716 Bytes

Versions: 15

Compression:

Stored size: 716 Bytes

Contents

# frozen_string_literal: true

class <%=name%>Importer < ApplicationImporter
  # Whether the excel sheet should contain a header
  includes_header true
  # Whether to allow importing of duplicates
  allow_duplicates false
  # Whether to ignore the given header and use our internal mapping
  ignore_header false

  field 'id', 'record ID of the <%=name%> (only if you want to update)'
  field 'name', 'name of the <%=name%>'

  # Here you will build the record based on the row
  def build(row)
    record = <%=name%>.find_or_initialize_by(id: row['id'])
    record.name = row['name']
    record
  end

  # Uncomment if you need to do something before saving the record
  # def before_save(record, _row)
  # end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
importo-3.0.21 lib/generators/importo/templates/importer.rb
importo-3.0.20 lib/generators/importo/templates/importer.rb
importo-3.0.19 lib/generators/importo/templates/importer.rb
importo-3.0.18 lib/generators/importo/templates/importer.rb
importo-3.0.17 lib/generators/importo/templates/importer.rb
importo-3.0.16 lib/generators/importo/templates/importer.rb
importo-3.0.15 lib/generators/importo/templates/importer.rb
importo-3.0.14 lib/generators/importo/templates/importer.rb
importo-3.0.13 lib/generators/importo/templates/importer.rb
importo-3.0.12 lib/generators/importo/templates/importer.rb
importo-3.0.11 lib/generators/importo/templates/importer.rb
importo-3.0.10 lib/generators/importo/templates/importer.rb
importo-3.0.9 lib/generators/importo/templates/importer.rb
importo-2.0.5 lib/generators/templates/importer.rb
importo-2.0.4 lib/generators/templates/importer.rb