Last active
March 10, 2024 19:13
-
-
Save k41n3w/418296cf3cef201f7d8bb6e908544a18 to your computer and use it in GitHub Desktop.
importando-dados-com-rails-na-velocidade-da-luz-1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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