类似于this问题,但那里的答案不起作用。
在routes.rb
scope '/api/ do
namespace :v1 do
scope :reports do
get '/reportXYZ', to: 'reports#reportXYZ'
end
end
end
在app/controllers/V1/reports_controller.rb
module V1
class ReportsController < ApplicationController
def reportXYZ
...
end
end
end
错误:
仅限Windows上的 uninitialized constant V1
,在ubuntu上运行正常。怎么样?
答案 0 :(得分:0)
In your routes .rb file instead of writing scope for api write like this
namespace :api do
namespace :v1 do
scope :reports do
get '/reportXYZ', to: 'reports#reportXYZ
end
end
end
And in your controller
module api
module V1
class ReportsController < ApplicationController
def reportXYZ
...
end
end
end
END