I\'m looking for a clean way to create a record with a set of attributes if the record does not exist and - if the record do exist - to update its attributes. I love the syn
Try this:
c = Category.find_or_initialize_by_id(category.id) c.name = category.name c.save!
This way you only save the instance once, instead of twice, if you called find_or_create_by_id (assuming it's a new record).
find_or_create_by_id