Skip to content

Instantly share code, notes, and snippets.

@jonpaul
Created December 6, 2011 16:56
Show Gist options
  • Save jonpaul/1438941 to your computer and use it in GitHub Desktop.
Save jonpaul/1438941 to your computer and use it in GitHub Desktop.
if params[:map_listing][:file]
file_field = params[:map_listing][:file]
session[:map_fields] = {}
temp_path = File.join(Dir::tmpdir, "map_fields_#{Time.now.to_i}_#{$$}")
File.open(temp_path, 'wb') do |f|
f.write file_field.read
end
session[:map_fields][:file] = temp_path
end
CSV.foreach(session[:map_fields][:file], { :headers => true, :return_headers => true }) do |row|
@import_headers = row if row.header_row?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment