How to update a few attributes from the model
-
How to update some of the model's at "+=1"
model.update("in = in + 1, out = out + 1")
Makes a mistake.
When assigning attributes, you must pass a hash as an argument.
The annex works at the Postgres database.
-
You're handing over the line. ActiveRecord doesn't know what to do with it. Method
update
He's waiting.It'll look like this.
model.update(in: (model.in + 1), out: (model.out + 1))
or so:
model.update_attributes(in: (model.in + 1), out: (model.out + 1))
update
andupdate_attributes
- Same thing. The second method is alas for the first.