samedi 29 octobre 2016

NameError in ProjectsController#index

In my rails app I am getting the following error:

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

My routes look like this:

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

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

And the problem controller:

 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

My investigations so far showed that Project is not yet initialized, but this shouldn't matter as it is a constructor, in its own class. I even tryed precompiling that by adding this line config.autoload_paths += %W( #{config.root}/app/controllers) to application.rb. Nothing seems yet to work. Any ideas will be greatly appreciated. Thanks!

Aucun commentaire:

Enregistrer un commentaire