ruby on rails - Best practise for updating single attribute on multiple records -


i writing exporter within current rails3 project right now. exporter has mark every exported record "exported" (bool). know how in loop, honestly, doesn't feel let rails query database, say, 300 times in row, set 1 field on 300 records.

does know if there's way optimize this? should play manually prepared statements, or rails3 take care of automagically? there sql command in 1 step or something?

thanks help

  • arne

use update_all method on class. rails api:

# update books 'rails' in title book.update_all "author = 'david'", "title '%rails%'" 

Comments

Popular posts from this blog

jQuery clickable div with working mailto link inside -

java - Getting corefrences with Standard corenlp package -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -