ActiveResource can be used with nested resources, provided you need to pass the parameters accordingly. ActiveResource call it as prefix options
that used with nested resource. Its a bit tricky to pass the prefix options to different methods, since methods use different approach to accept prefix params. Lets consider we have a model for Inventory like on below,
The prefix option :store_id
is passed to various method in different ways. Make sure you use the same key as you specified in the self.prefix
.
On find()
For find()
method you can pass the :store_id
in :params
hash, as second parameter.
On save()
For save()
you can’t pass it as second parameter. So you need to explicitly set on the object before calling the .save()
method.
On update_attributes()
.update_attributes()
won’t accept any second parameter, so you need to pass it with other params.