1

这是我的设置:

路线:

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

4

1 回答 1

2

据我所知,只有namespaces 和scopes 需要一个嵌套模块。

于 2017-10-15T10:38:34.643 回答