Rails:未初始化的常量控制器

时间:2017-10-15 10:15:51

标签: ruby-on-rails ruby controller routes uninitialized-constant

这是我的设置:

路线:

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

1 个答案:

答案 0 :(得分:2)

据我所知,namespacescope需要嵌套模块。

相关问题