I am using ActiveResource in Rails to manage objects in a separate database through REST.
I am trying to explicitly manage the identifiers of the remote resources, since for the current case itβs easier to just reuse the identifier of the local resource and not support another field.
Unfortunately, I was not able to get this to work, since the code is new? in ActiveResource::Base there is
def new? id.nil? end
and save is
def save new? ? create : update end
So, from this, by definition, it is impossible to set the resource identifier and save it as a new resource.
create and update are protected methods, so if I hacked ActiveResource :: Base, maybe that would make it work, but I don't want to.
Is there a proper way to do this? Or is it what I'm trying to do is just bad, and I should not do this?
rest ruby-on-rails activeresource
DanSingerman
source share