You can also iterate over each of them using each
and using the values of each key
on the array of hashes.
[
{ app_id: 2, user_id: 3, created_at: '2017-04-07', updated_at: '2017-04-07', unique: 12, valoracion: 4.8, valoracions_id: 1 },
{ app_id: 2, user_id: 3, created_at: '2017-04-07', updated_at: '2017-04-07', unique: 12, valoracion: 4.8, valoracions_id: 1 },
{ app_id: 2, user_id: 3, created_at: '2017-04-07', updated_at: '2017-04-07', unique: 12, valoracion: 4.8, valoracions_id: 1 }
].each do |rating|
Rating.create(
app_id: rating[:app_id],
user_id: rating[:user_id],
created_at: rating[:created_at],
updated_at: rating[:updated_at],
unique: rating[:unique],
valoracion: rating[:valoracion],
valoracions_id: rating[:valoracions_id]
)
end
And if you want to gain some time you can use Active Record Transactions in the case of make many records.
ActiveRecord::Base.transaction do
...
end