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
Post a Comment