I took a look a this question and didn't found any answer that worked for me.
I have, for example a Project model, which has_many tasks. I would like to create, from an array of attributes, many tasks for some project. So, in my project model, I would have a method like this (simplified example):
def create_tasks(tasks)
tasks.map{|t| Task.create(project: self, name: t.name)}
end
The problem is, for each task, it will make a hit on my db, and for a large number of records that wouldn't be desirable. How could I do that so ActiveRecord will make only one call to my database? Thanks in advance!