so if I have an array of hashes like so: (ruby beginner)
input = [
{\"last_name\"=>\"Gay\", \"first_name\"=>\"Rudy\", \"display_name\"=>\"Rudy Gay
Given your input:
input = [
{ "last_name"=>"Gay", ... },
{ "last_name"=>"Collison", ...}
]
If all of those keys (last_name, first_name, display_name) are present in the Player
model, you can just:
input.each do |x|
Player.create(x)
end
Since create
will take a hash of attributes to assign. But, even better, you don't even need to iterate:
Player.create(input)
ActiveRecord will go through them all if you give it an array of hashes.