ruby on rails - how to update_attributes with the conditions? -


I need to update the attributes but only for specific conditions such as rows

  [" 

How do I do this?

P>

It depends on whether you want to update a bulk SQL, or want to update on each model which also calls verification and normal callback series.
if You Want to translate and run the callback chain:

  Model.find (: all, conditions => ["recipient_id =? And inbox_id =? And condition = 'unread'" , Current_user.id, @ inbox.id]) .org | obj | Obj.update_attributes (...) end  

If you want to update SQL:

< Pre> Model.update_all ("attr1 = 'something', Attr2 = true, ...", ["recipient_id =? And inbox_id =? And condition = 'unread'", current_user.id, @inbox.id ])

Be sure to

to ensure that you properly avoid your SQL array of situations. Use the formula

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -