ruby on rails 3.2 - How can I specify prefix parameters when saving a nested ActiveResource? -
i have nested activeresource model (i.e. it's within model's namespace). trying call save raises:
activeresource::missingprefixparam: client_id prefix_option missing how supply needed prefix?
here's class:
class foo::bar < activeresource::base self.site = "http://www.example.com" self.prefix = "/clients/:client_id" self.element_name = "policy" self.collection_name = "policies" end here's save attempt:
bar = foo::bar.new :client_id => 123 bar.valid? # => true bar.client_id # => 123 bar.save # => activeresource::missingprefixparam... time , again i've looked elucidation on this, find same instruction:
when requested nested resource , don’t provide prefix_param activeresource::missingprefixparam raised.
i'm trying access our server's api endpoint @ http://www.example.com/clients/[client_id]/policies, i'm apparently failing supply client_id, app makes request http://www.example.com/clients//policies
the server log tells me: actioncontroller::routingerror (no route matches "/clients//policies/" {:method=>:post}).
it work if create method prefix_options, supplies hash containing needed client_id prefix_option, so:
def prefix_options { :client_id => client_id } end
Comments
Post a Comment