You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In theory adding require_prefix: 'v' to the api call in the router should do exactly that - I'll take a look and see if I can recreate it locally / work out what's going wrong.
Ok, so the main bug that remains is in route generation - I have it working locally, but the issue is it unpacks the version from v1 to 1 (the numeric version), and then route generation fails - for requires_prefix at least.
This is one of the issues with the named version stuff, and needs a bit more work to get to the root of the issue - For the moment, you should be able to use require_prefix and explicitly pass in version: 'v1' when you generate the url.
@johnrees I've been playing with this versioning prefix myself this morning and seem to have it running quite nicely.
As suggested by @Sutto you need to add the prefix definition to your api call in your routes. You have two options, a required or an optional prefix, however the call in the routes definition uses require_prefix or allow_prefix.
constraints subdomain: 'api' do
get '/' => 'static#api'
api versions: 1, module: "api/v1", allow_prefix: "v" do
resources :labs, only: [:index]
end
end
As a side note, if you have any routing specs in place for your API you'll need to add:
to the expected request parameters for the route once you've enabled to the prefix, and also change your expected "version" request parameter from 1 to v1.
Apologies if I'm missing something extremely obvious. I've dug through https://github.com/filtersquad/rocket_pants/blob/master/lib/rocket_pants/routing.rb and tried using required_prefix, optional_prefix in my routes.rb to no avail.
Purely for vanity reasons I was hoping to have urls like https://api.mydomain.com/v1/objects following the docs I've got to https://api.mydomain.com/1/objects and it works great. So my question is, is there a simple way to add the 'v'?
The text was updated successfully, but these errors were encountered: