这是我的设置:
路线:
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
点击链接时,出现以下错误:
未初始化的常量PlatformsController
为什么Rails会查找PlatformsController
而不是Apps::PlatformsController
?
答案 0 :(得分:2)
据我所知,namespace
和scope
需要嵌套模块。