activerecord - rails - updating active record relation with multiple changed properties -


i have active record relation defined this:

contacts = contact.where("status = 'waiting'") 

i run .each loop , change properties of contacts depending on logic.

i don't want save! on each individual contact... how can better save entire contacts relation after loop?

contacts.each |contact|          //change properties of contact here  end 

how save newly updates contacts activerecord relation after contains new properties?

the efficient way can't doing contact contact save.

update_all saves doing loop , save you, here documentation. https://apidock.com/rails/v4.0.2/activerecord/relation/update_all


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -