Pry Flack <[email protected]> wrote: > Soichi Ishida wrote in post #1112146: > > Rails 4.0.0 > > Of course, I can loop through all elements like > > > > Info.all.each do | i | > > if i == ... then > > Info.create(... => i) > > end > > end > > > > But it seems inefficient. > > > > Is there better ways or gems that do the job I am looking for? > > > > soichi > > Not sure I understand fully your problem. > > Maybe use find_in_batches ? > http://api.rubyonrails.org/classes/ActiveRecord/Batches.html > > or find_and_create_by_column_name ? > http://api.rubyonrails.org/classes/ActiveRecord/Base.html
It's also not clear to me what you're doing with the items. From your snippet of pseudocode, you want to *create* a *new* item with the matching item when you find a match?? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/51b93e1b.aa2b320a.14be.fffffa56%40mx.google.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.

