Skip to content

Instantly share code, notes, and snippets.

@TXDynamics
Created June 5, 2013 20:45
Show Gist options
  • Save TXDynamics/5717180 to your computer and use it in GitHub Desktop.
Save TXDynamics/5717180 to your computer and use it in GitHub Desktop.
Ruby on Rails: Import a csv file into a database and adding an additional static value column
file_path = 'public/uploads/' + filename
marketer = Marketer.find(marketer_id)
CSV.foreach(file_path, headers: true) do |row|
MarketerImport.create! row.to_hash.merge(new_user: marketer.slx_id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment