views:

28

answers:

1
INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE a='4', b='5', c='6'

how to implement this type(insert and update) of sql in rails in single statement if possible

A: 

You can run your sql directly:

sql = "INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE a='4', b='5', c='6'"
ActiveRecord::Base.connection.insert_sql sql
jdeseno