配置控制器但出现错误ActionNotFound

Bla*_*543 1 ruby ruby-on-rails

我是否正确配置默认路由?目前,我的路线设置为:

root :to => 'proto#index'
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我收到以下错误:

AbstractController::ActionNotFound (The action 'index' could not be found for ProtoController):
Run Code Online (Sandbox Code Playgroud)

我需要更改什么文件?

dec*_*lan 5

您正在寻找app / controllers / proto_controller.rb

它应该包含如下内容

class ProtoController < ApplicationController

  def index
  end

end
Run Code Online (Sandbox Code Playgroud)

然后,您想要在app / views / proto / index.html.erb中创建一个包含页面html的文件。