Reputation: 237
ANSWER IN FINAL EDIT
I'm running a project using Rails 3.1.3. I only have one page web page and my application contoller looks like this:
class ApplicationController < ActionController::Base
protect_from_forgery
def index
end
end
and a route
root :to => 'application#index'
in routes.rb.
When I load the page I get this error in a body:before html tag at the top of my page (otherwise the content seems to load fine)
NoMethodError: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[]
Nothing shows up in my console where the server is running, and there is no information about where the error occurs.
As you can see, I have no idea where to start looking for this nil instance. Can anyone give me an idea of what might be going on here?
Edit: including the contents of my routes.rb file
ProjectName::Application.routes.draw do
root :to => 'application#index'
end
FINAL EDIT:
I had the project running in a different folder and recently moved it over. Turns out compass was throwing an error (thus why it was being thrown into my body html tag) despite loading the stylesheets fine. I needed to run compass clean
then compass compile
, I guess to make Compass aware of the new path. Thanks for the help everyone!
btw here is my Gemfile
source :gemcutter
gem 'rails', '3.1.3'
gem 'sqlite3'
gem 'json'
gem 'rails_config', '0.2.4'
gem 'jammit', '0.6.5'
gem 'compass', '0.11.3'
gem 'haml', '3.1.2'
gem 'jquery-rails'
Upvotes: 0
Views: 310
Reputation: 23556
I don't think that it is good idea to have any display methods in ApplicationController
. Try run
rails g controller welcome
and there add your index
and route to this by
root :to => 'welcome#index`
EDIT
After posting your Gemifile
I saw where is problem. It's caused by that Comapss 0.11 isn't compatible with Rails 3.1. You must use alpha release. Change Compass version to:
gem 'compass', '~> 0.12.alpha.0'
Upvotes: 1
Reputation: 26
Perhaps it's occurring in index.html.erb file. Please, check if you are running on development environment, instead of 'production.' Then check the development.log file.
Upvotes: 0