I have been using ActiveResource in my Ruby on Rails applications for some time, and I am starting to really feel that it needs a final polish to make it go from "pretty nice" to "beautiful".
I would like to be able to use an ActiveResource as if it were an ActiveRecord. If I could use has\_many
, belongs\_to
and other niceties with ActiveResources, it would make my life easier.
So I looked around for a plugin to do just that, but haven't had any luck finding one. Has anyone written one? Does anyone know of an ongoing project?
Raison d'être
Let's say I have an application which manages Users
, and another application which manages UserRequests
. I would like to avoid any circular dependency between my applications, therefore I have decided that the Users
application will be completely unaware of the notion of UserRequests
. But of course, a UserRequest
should belong to a User
, and a User
should have many UserRequests
.
So, in the Users
application, all I have is a User
ActiveRecord, with all the necessary controller stuff to make it usable through ActiveResource.
The complicated stuff is in the UserRequests
application. I have a UserRequest
ActiveRecord, and a User
ActiveResource. I would love to code the fact that a UserRequest
belongs_to
a User ActiveResource, and a User
ActiveResource has_many
UserRequests
.
In another scenario where it could be the other way around (the ActiveRecord has_many
ActiveResources, and the ActiveResource belongs_to
the ActiveRecord).