繁体   English   中英

Rails 3.1中的路由错误

[英]Routing error in Rails 3.1

我当然为此失去了头/睡眠。 这是我的questions_controller.rb

class QuestionsController < ApplicationController
  # GET /questions
  # GET /questions.json
  def index
    @questions = Question.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @questions }
    end
  end

这是我的applications_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery
end

这是我的耙路:

    questions GET    /questions(.:format)          questions#index
              POST   /questions(.:format)          questions#create
 new_question GET    /questions/new(.:format)      questions#new
edit_question GET    /questions/:id/edit(.:format) questions#edit
     question GET    /questions/:id(.:format)      questions#show
              PUT    /questions/:id(.:format)      questions#update
              DELETE /questions/:id(.:format)      questions#destroy
   home_index GET    /home/index(.:format)         home#index

这是我的routes.rb

App::Application.routes.draw do
  resources :questions
end

转到http://0.0.0.0:3000/questions出错

uninitialized constant QuestionsController

可能是什么错误?

当其中一个文件中存在语法错误时,有时会发生此类错误。 重新启动开发服务器,并在其输出中查找错误。

特别是检查线

format.html # index.html.erb

我不认为可以这样写。

您可以确保控制器文件名采用正确的复数形式吗?

app/controllers/questions_controller.rb

谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM