jensb / create_or_update_by

Extends Ruby on Rails's ActiveRecord::Base to mimick MySQLs "REPLACE INTO" for all databases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CreateOrUpdateBy
================

This plugin mimicks something like MySQL REPLACE INTO mechanism, in which you
can specify a primary key, and depending on whether a record exists already, it
will be replaced or newly created.

This plugin does the same, but allows not only primary keys to be specified as search
conditions, but ANY column, or ANY two columns.

Idea and longer introduction:
  http://www.intridea.com/2008/2/19/activerecord-base-create_or_update-on-steroids-2

Idea for extension to include two find parameters / conditions (found via Google):
  http://github.com/jeremymcanally/docbox/tree/57215361c3a585a9608bee25cd6e4659c780ff17/lib/core_ext.rb

Tests, pluginization and documentation: me.


Copyright (c) 2009 Jens Benecke <jens-rails@spamfreemail.de>, released under the MIT license.

About

Extends Ruby on Rails's ActiveRecord::Base to mimick MySQLs "REPLACE INTO" for all databases.

License:MIT License


Languages

Language:Ruby 100.0%