最终编辑中的答案
我正在使用 Rails 3.1.3 运行一个项目。我只有一页网页,我的应用程序控制器如下所示:
class ApplicationController < ActionController::Base
protect_from_forgery
def index
end
end
和一条路线
root :to => 'application#index'
在 routes.rb 中。
当我加载页面时,我在正文中收到此错误:在页面顶部的 html 标记之前(否则内容似乎加载正常)
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.[]
我的控制台中没有显示服务器正在运行的地方,也没有关于错误发生位置的信息。
正如你所看到的,我不知道从哪里开始寻找这个 nil 实例。谁能告诉我这里可能发生的事情?
编辑:包括我的 routes.rb 文件的内容
ProjectName::Application.routes.draw do
root :to => 'application#index'
end
最终编辑:
我让项目在不同的文件夹中运行,最近将它移了过来。事实证明,尽管加载样式表很好,但指南针还是抛出了一个错误(因此它被抛出到我的 body html 标记中)。compass clean
然后我需要运行compass compile
,我想让 Compass 知道新路径。感谢大家的帮助!
顺便说一句,这是我的 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'