S
S
Shaks2015-02-22 13:13:33
Ruby on Rails
Shaks, 2015-02-22 13:13:33

RoR. ON DUPLICATE KEY UPDATE `amount` = `amount`+1. Already blown my mind. How?

I’ll clarify right away that the option ActiveRecord::Base.connection.insert(......)is already at the worst possible end.
Model.(create/find)_or_initialize_by(...)- absolutely not.
The search for answers began with the activerecord-import jam , because mass inserts are just planned. It has on-duplicate-key-update , but I didn’t figure out how to use it (How to change one value to another is understandable, but how to do `int_column` = `int_column`+1, this remains a mystery to me.
Help figure out who might come across it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsuhachev, 2015-02-23
@shaks

Take a look at the source , everything is simple there :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question