Posts Tagged ‘activerecord’

ActsAsInsertOrUpdate

Problem

With high volume Rails applications, entities with unique constraints are expensive and error prone to create/update. ActsAsInsertOrUpdate helps solve that problem (if you’re using MySQL), by leveraging the “INSERT … ON DUPLICATE KEY UPDATE” functionality.

Scenario
Lets say you have a Person, and Entity, and a Rating. Each user can rate each entity only once, and [...]