Update set with value in table rails

How can I do something like:

UPDATE table SET boolean = !boolean WHERE conditions

With an ActiveRecord model (Without using two queries)?

Upvotes: 0

Views: 922

Answers (1)

Taekmin Kim
Taekmin Kim

Reputation: 151

users table in mysql

 active : tinyint(2)

in rails console

 User.update_all("active = !active", conditions)

Upvotes: 1

Related Questions