Rails: 未初始化的常量控制器
Rails: uninitialized constant Controller
这是我的设置:
路线:
resources :apps, except: [:index, :new], path: 'a' do
resources :platforms, only: [:update]
end
控制器:
class Apps::PlatformsController < ApplicationController
before_action :authenticate_user!
before_action :set_platform
# PATCH/PUT /apps/1/platforms/1
# PATCH/PUT /apps/1/platforms/1.json
def update
# do stuff ...
end
private
# Use callbacks to share common setup or constraints between actions.
def set_platform
@platform = App::Platform.find params[:id]
end
end
查看:
= link_to 'Update', app_platform_url(platform.app.slug, platform.id), method: :put
单击 link 时,出现以下错误:
uninitialized constant PlatformsController
为什么 Rails 寻找 PlatformsController
而不是 Apps::PlatformsController
?
据我所知只有 namespace
s 和 scope
s 需要嵌套模块。
这是我的设置:
路线:
resources :apps, except: [:index, :new], path: 'a' do
resources :platforms, only: [:update]
end
控制器:
class Apps::PlatformsController < ApplicationController
before_action :authenticate_user!
before_action :set_platform
# PATCH/PUT /apps/1/platforms/1
# PATCH/PUT /apps/1/platforms/1.json
def update
# do stuff ...
end
private
# Use callbacks to share common setup or constraints between actions.
def set_platform
@platform = App::Platform.find params[:id]
end
end
查看:
= link_to 'Update', app_platform_url(platform.app.slug, platform.id), method: :put
单击 link 时,出现以下错误:
uninitialized constant PlatformsController
为什么 Rails 寻找 PlatformsController
而不是 Apps::PlatformsController
?
据我所知只有 namespace
s 和 scope
s 需要嵌套模块。