so if I have an array of hashes like so: (ruby beginner)
input = [
{"last_name"=>"Gay", "first_name"=>"Rudy", "display_name"=>"Rudy Gay", "position"=>"SF", "minutes"=>39, "points"=>25, "assists"=>6},
{"last_name"=>"Collison", "first_name"=>"Darren", "display_name"=>"Darren Collison", "position"=>"PG", "minutes"=>39, "points"=>14, "assists"=>4}
]
how would i iterate through the array as well as to iterate through each hash to have something like this:
player1 = {display_name=>"rudy gay", "position"=>"SF"}
player2 = {display_name=>"darren collison", "position"=>"PG"}
Would it be something like
input.each do |x|
Player.create(name: x['display_name'], position: x['position']
end
(assuming I have a player model)
Is there a better way to achieve this?
Thanks!