class Object

Public Class Methods

headers() click to toggle source

Map attributes to your spreadsheet columns (0-based). You can use a hash { attr1: 0, attr2: 1, attr3: 2, … } or an array %w(attr1 attr2 attr3 …) (which maps each key to their index).

# File lib/generators/rails/templates/spreadsheet.rb, line 12
def self.headers
  {<%= @attributes.map.with_index{|a,i| "#{a}: #{i}"}.join(', ') %>}
end

# Set the row number where the data start, default is 2 (1-based)
def self.starting_row
  2
end

# Returns 1 or more ActiveRecord classes where data will be saved
def self.models
  [<%= @models.count == 1 ? @models.first : @models.join(', ') %>]
end