未初始化常数的问题

时间:2010-04-16 20:38:25

标签: ruby-on-rails

我有以下控制器

class ActiveUsersController < ApplicationController

def edit
end

我的routes.rb是这样的:

map.resources :active_users

当我尝试使用网址http://localhost:3000/active_users/COo8e45RqQAHr6CqSCoI/edit访问控制器时出现以下错误:

NameError in Active usersController#edit

uninitialized constant ActiveUsersController
RAILS_ROOT: /Users/vintem/Documents/Projetos/Pessoal/bugfreela

Application Trace | Framework Trace | Full Trace
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in `constantize'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `constantize'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in `constantize'
/Users/vintem/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:443:in `recognize'
/Users/vintem/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:436:in `call'

任何人都可以帮助我吗?

由于

1 个答案:

答案 0 :(得分:0)

resources指的是模型和假设的相关控制器,命名方式相似。你有ActiveUser模特课吗?或者是其他什么,比如说User? E.g:

map.resources users, :controller => "active_users"

查看API文档: http://api.rubyonrails.org/classes/ActionController/Resources.html

很难确切地告诉您提供的信息有什么问题。