Rails:不支持的控制器名称

时间:2019-02-25 22:26:23

标签: ruby-on-rails routes ruby-on-rails-5

我的路线命名方式有什么问题?

我是否需要将文件夹结构和模块名称更改为

  scope module: 'CarRegistration' do
    resources :steps
  end

如果可能的话,我希望使用现有的格式。

路线

module CarRegistration
  class StepsController < ApplicationController
    include Wicked::Wizard
    steps :step1, :step2, step3

    def show
      @form_object_model ||= form_object_model_for_step(step)
      render_wizard
    end

    def update
      @form_object_model = form_object_model_for_step(step)
      render_wizard @form_object_model
    end

    private

    def form_object_model_for_step(step)
      "CarRegistration::#{step.camelize}".constantize.new      
    end

  end
end

控制器

/app/controllers/CarRegistration/steps_controller.rb

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'import/data' with dtype float and shape [1,3,224,224]
     [[node import/data (defined at /Users/fredeli/gitprojects/ai_compendium/test_onnx.py:27)  = Placeholder[dtype=DT_FLOAT, shape=[1,3,224,224], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

错误

  

“ CarRegistration / steps”不是受支持的控制器名称。这个可以   导致潜在的路由问题。看到   http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use   (ArgumentError)

1 个答案:

答案 0 :(得分:1)

您似乎至少有两个问题。您使用的文件夹结构如下:

app/controllers/CarRegistration/steps_controller.rb

那是非常规的。相反,它应该是:

app/controllers/car_registration/steps_controller.rb

然后,您的路线应如下所示:

scope module: :car_registration do 
  resources :steps
end