I am using ActiveResource in Rails to manage entities in a separate database over REST.
I have been trying to explicitly manage the IDs of the remote resources, as for the current case it is simplest to just re-use the local resource's ID, rather than maintain a different field.
Unfortunately I have not been able to get this working as the code for new?
in ActiveResource::Base
is
def new?
id.nil?
end
and save
is
def save
new? ? create : update
end
So from that by definition it is impossible to set an ID of a resource and save it as a new resource.
create
and update
are protected methods, so if I hacked the ActiveResource::Base code perhaps that would make it work, but I am loath to do that.
Is there a correct way of doing this? Or is what I am trying to do just bad, and I shouldn't do it?