Closed l4u closed 9 years ago
Currently I can change the URL after the :id is mapped to it. Is there a way I can change the value of :id before the URL mapping?
I don't understand the bug report/problem? Using your code from the other ticket:
class Item < ActiveRestClient::Base
base_url "http://api.my-url.com/v2"
username 'username'
password 'password'
get :all, "/list/"
get :find, "/items/:id"
end
To change the ID, you pass a different value in to the #find
method, e.g.
Item.find(id: "Whatever you want here")
If you want it escaping, you can do that yourself (I wouldn't want to automatically escape them, just in case someone's API requires that they aren't escaped, or are escaped in some other way).
You can also adjust the ID within a filter - https://github.com/whichdigital/active-rest-client#using-filters
At before_request
it seems that I can get the full URL, but not the :id in get_params.
Currently, I can do Item.find(id: CGI.escape(item_id))
. But is there a good place that I can move the CGI.escape
into the model instead of placing it at the controller? THANKS!
There's nowhere easy. This may be something that's possible with a Proxy, but I haven't tried.
What type of value are you passing in the ID field that need escaping?
The ID is an e-mail address. Maybe I will just use the above workaround. Thanks!
related #94