当我尝试查看localhost:3000/galleries
undefined method `sub' for nil:NilClass
我的日志文件告诉我
ActionController::RoutingError (undefined method ‘sub’ for nil:NilClass)`
app/controllers/galleries_controller.rb:1:in `<top (required)>'
Rendered /Users/mikev/.rvm/gems/ruby-1.9.3-head/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)
的routes.rb
Gallery::Application.routes.draw do
match 'galleries' => 'galleries#index'
end
控制器/ galleries_controller.rb:
class GalleriesController < ApplicationController
def index
end
end
views / galleries / index.html.erb为空
知道这意味着什么吗?
答案 0 :(得分:8)
当路由器尝试查找常量名称并失败时,通常会发生此问题。
你有app / helpers / galleries_helper.rb的助手吗?如果是这样,它是否定义了GalleriesHelper?