在我的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
尚未初始化,但这并不重要,因为它是一个构造函数,在它自己的类中。我甚至尝试通过将此行config.autoload_paths += %W( #{config.root}/app/controllers)
添加到application.rb
来预编译。似乎没有什么工作。任何想法将不胜感激。谢谢!
答案 0 :(得分:0)
[解决]:
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
现在应该修复了!