Last active
March 10, 2024 19:13
-
-
Save k41n3w/a3ce96b6fedc1abcc50edb2c63d4ac1b to your computer and use it in GitHub Desktop.
importando-dados-com-rails-na-velocidade-da-luz-2
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
file_path = 'caminho/para/seu/arquivo.csv' | |
users_data = [] | |
CSV.foreach(file_path, headers: true) do |row| | |
users_data << {name: row['name'], email: row['email']} | |
end | |
User.insert_all(users_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment