Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save k41n3w/418296cf3cef201f7d8bb6e908544a18 to your computer and use it in GitHub Desktop.
Save k41n3w/418296cf3cef201f7d8bb6e908544a18 to your computer and use it in GitHub Desktop.
importando-dados-com-rails-na-velocidade-da-luz-1
# Supondo que o modelo seja User com os campos name e email
require 'csv'
file_path = 'caminho/para/seu/arquivo.csv'
CSV.foreach(file_path, headers: true) do |row|
User.create(name: row['name'], email: row['email'])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment