I need to update attributes but only for rows with the specific conditions like
["recipient_id = ? and inbox_id = ? and status='unread'", current_user.id, @inbox.id]
How do I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on if you want to do a bulk SQL update, or do an update on each model that also calls validation and the normal callback chain.
If you want to instantiate the objects and run the callback chain do:
If you want to do the SQL update:
Make sure to use the array form of conditions to ensure you correctly escape your SQL.