Saving multiple objects in a single call in rails

后端 未结 6 482
無奈伤痛
無奈伤痛 2020-12-12 13:25

I have a method in rails that is doing something like this:

a = Foo.new(\"bar\")
a.save

b = Foo.new(\"baz\")
b.save

...
x = Foo.new(\"123\", :parent_id =&g         


        
6条回答
  •  Happy的楠姐
    2020-12-12 13:47

    You don't need a gem to hit DB fast and only once!

    Jackrg has worked it out for us: https://gist.github.com/jackrg/76ade1724bd816292e4e

提交回复
热议问题