belongs_ associations to models inherited from ActiveResource::Base
Say, you have Author and a service with Profiles. You can access profile of author as easy as
Also, if you have 10K profiles and you need 3 of them, it won't load all profiles and won't do 3 requests to API.
Instead, just use
Author.scoped.includes_remote(:profile) and it will do a get request like this one:
Don't want to use default
author_id? You can alter class of
profile association and
author_id key by options.
Just like in ActiveRecord.
Notice, that for now, associations work in read-only mode.
class Profile < ActiveResource::Base self.site = REMOTE_HOST end class User < ActiveRecord::Base include RemoteAssociation::Base has_one_remote :profile end User.first.profile
Add this line to your application's Gemfile:
Implement 'has_many_remote' analogie of 'AR.has_many'
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request