Your load_imported_products
method includes an each
block. That block is the last 'line' of your method, so the return value of the block becomes the return value of the method.
Try the following:
def load_imported_products
spreadsheet = open_spreadsheet
header = spreadsheet.row(1)
products = []
(2..spreadsheet.last_row).each do |i|
row = Hash[[header, spreadsheet.row(i)].transpose]
product = Product.find_by_id(row['id']) || Product.new
product.attributes = row.to_hash.slice(*accessible_attributes)
products << product
end
products
end