Closed jtmkrueger closed 9 years ago
Have you tried reversing your get
lines in the proxy? From memory each get
registers a handler and the proxying stops with the first match. So this may work better:
class ApiCoalitionProxy < ActiveRestClient::ProxyBase
get "/coalitions/:id" do
# ...
end
get "/coalitions" do
# ...
end
end
Let me know if that resolves it (and if so I'll make it clearer in the README).
Thanks for reporting the issue.
Unfortunately, no luck. Here's what I tried:
class ApiCoalitionProxy < ActiveRestClient::ProxyBase
get "/coalitions/:id" do
response = passthrough
translate(response) do |body|
result = body['result']
result
end
end
get "/coalitions" do
response = passthrough
translate(response) do |body|
result = body['result']
result
end
end
end
class ApiCoalition < ActiveRestClient::Base
proxy ApiCoalitionProxy
base_url 'https://cleancities-stage.nrel.gov/api/v1/'
get :all, '/coalitions'
get :find, '/coalitions/:id'
end
Well, it looks like this is my fault. It was caching in my development environment. Once I turned that off, things started looking right!
LOL. No worries, glad you found the answer (I was wondering what on earth was going on and was going to build a test project to replicate it).
I'm trying to proxy find:
The all method works just fine, but I'm not sure what I'm doing wrong with my find method. No attempt to use it is successful.
Just doing
ApiCoalition.first(1)
proves that it's still hidden behindresult
. What am I doing wrong?Perhaps expanding the example in the README would benefit others that could run into this.