ProjectsController#index 中的 NameError

NameError in ProjectsController#index

在我的 rails 应用程序中出现以下错误:

NameError in ProjectsController#index
app/controllers/projects_controller.rb:6:in `index'

我的路线是这样的:

RailsStarter::Application.routes.draw do
resources :projects

root :to => 'pages#home'
match '/' => 'pages#home'
match '/overview' => 'pages#overview'
match '/recruitmentInfo' => 'pages#recruitmentInfo'

问题控制器:

 class ProjectsController < ApplicationController

 # GET /projects
 # GET /projects.json
 def index
 @projects = ::Project.all

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

到目前为止,我的调查显示 Project 尚未初始化,但这应该无关紧要,因为它是一个构造函数,在它自己的 class 中。我什至尝试通过将这一行 config.autoload_paths += %W( #{config.root}/app/controllers) 添加到 application.rb 来对其进行预编译。似乎还没有任何效果。任何想法将不胜感激。谢谢!

[已解决]:

1 Reboot machine - the command must interfere with another server process
2 Check active_support gem versions by running `gem list` and remove them all
3 Remove `Gemfile.lock`
3 Run `bundle install` - this will add back your new version of gemfile
4 Run `rails generate model Project` again

现在应该修复了!