Is it possible to override or set ActiveRecord::Base.new_record? I would
like to be able to do something like:
c = Category.new
c.id = 6
c.name = “updated name”
c.new_record? = false
This would execute an UPDATE statement instead of an INSERT.
The reason for my wanting to do this as follows:
I have a SOAP web service called ‘save_category’. It accepts a type
called ‘ApiCategory’ which has similar attributes. I have a helper
mapping from Category->ApiCategory and Category->ApiCategory.
I want the Api::save_category to do an insert when there is no
ApiCategory.id and to do an update when there is.
Any help would be much appreciated.