[Active Record] Add belongs_to_resource to active record
Pull Request Description
This pull request adds the belongs_to_resource class method to the ActiveResource Ruby on Rails gem. This method allows for the association of an ActiveResource with an ActiveRecord.
Changes Made
The belongs_to_resource method has been added to the ActiveResource::Base
class. This method takes two arguments: the name of the association and
class_name keyword argument. The options hash can include the class_name
option to specify the name of the ActiveResource class to associate with.
Example Usage
class Person < ActiveResource::Base
self.site = "http://api.people.com:3000"
end
class Address < ActiveRecord::Base
belongs_to_resource :person
end
With this association, an Address active record model can be associated with a Person active resource via the person_id foreign key. The Person object can be accessed through the person method on the Address object.
Testing
Unit tests have been added to ensure that the belongs_to_resource method works as expected. These tests cover the basic functionality of the method, as well as the use of the class_name.
Related Issue
This pull request is related to https://github.com/rails/activeresource/issues/292.
hi there, are there any updates on this one?