Closed joshuapinter closed 10 years ago
Try this
rails generate versionist:new_api_version v1 Api::V1 --path=value:v1 --default
rails generate versionist:new_controller products Api::V1
rails generate versionist:copy_api_version v1 Api::V1 v2 Api::V2
api_version(:module => "Api::V2", :path => {:value => "api/v2"}) do
...
end
Thanks @prasofty. I ran the following command:
rails generate versionist:copy_api_version v3 Api::V3 v4 Api::V4
This seemed to find the controllers just fine but did not find the routes okay, as per the following output:
No routes found in config/routes.rb for v3
Copying all files from app/controllers/api/v3 to app/controllers/api/v4
Also, the views were not copied.
Hey @joshuapinter I'm really sorry for the radio silence on this. I recently started working at a company that uses GitHub for its SCM, and for some reason that seems to have broken notifications to me about my personal repos. So I didn't see this until just now.
As for your issue, the following works for me:
rails generate versionist:copy_api_version api/v1 Api::V1 api/v2 Api::V2
route api_version(:module => "Api::V2", :header => {:name => "Accept", :value => "application/vnd.mycompany.com; version=1"}) do
end
Copying all files from app/controllers/api/v1 to app/controllers/api/v2
Copying all files from test/functional/api/v1 to test/functional/api/v2
Copying all files from test/integration/api/v1 to test/integration/api/v2
Copying all files from app/presenters/api/v1 to app/presenters/api/v2
Copying all files from test/presenters/api/v1 to test/presenters/api/v2
Copying all files from app/helpers/api/v1 to app/helpers/api/v2
Copying all files from test/helpers/api/v1 to test/helpers/api/v2
Copying all files from public/docs/api/v1 to public/docs/api/v2
Oh perfect, thanks @bploetz. I appreciate you closing the loop on this.
Cheers!
I have all of my API stuff in an
api
directory, for example:Because of this, a generator command, like:
Does not work because it cannot find anything in
app/controllers/v2/
, etc.:Here is my routes namespace for V2:
Thanks!