main:object的未定义局部变量或方法名称'projectname'

时间:2011-07-07 06:24:50

标签: ruby-on-rails ruby-on-rails-3 routes models

好的,所以我在启动rails服务器以及运行任何rake命令时遇到一些问题,因为它失败了一个未定义的局部变量或方法名称'Newventureclub'(这是我项目的名称)。在运行几次迁移并向路由文件添加一些路径后,这个错误就开始发生了,但即使是向后退步,我也似乎无法让它再次运行。跑--trace我明白了:

/Users/mbs89/webdev/nvc/newventureclub/config/routes.rb:1
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:127:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:120:in `routes_reloader'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application/finisher.rb:51
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in `call'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application/finisher.rb:52
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
/Users/mbs89/webdev/nvc/newventureclub/config/environment.rb:5
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:103:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:103:in `require_environment!'
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:216:in `initialize_tasks'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:205:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:176:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:157:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:62:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/bin/rake:32
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

当我尝试启动服务器时,我收到一条略有不同的错误消息:

undefined local variable or method `Newventureclub' for main:Object (NameError)
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:127:in `each'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:120:in `routes_reloader'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `call'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application/finisher.rb:51
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in `call'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application/finisher.rb:52
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
    from /Users/mbs89/webdev/nvc/newventureclub/config/environment.rb:5
    from /Users/mbs89/webdev/nvc/newventureclub/config.ru:3:in `require'
    from /Users/mbs89/webdev/nvc/newventureclub/config.ru:3
    from /Library/Ruby/Gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
    from /Library/Ruby/Gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
    from /Users/mbs89/webdev/nvc/newventureclub/config.ru:1:in `new'
    from /Users/mbs89/webdev/nvc/newventureclub/config.ru:1

这是我的路线文件,我认为是导致错误但我无法发现它:

Newventureclub::Application.routes.draw do

  resources :list_locations

  resources :list_controls

  resources :companies  
  get "all_members" => "main#members", :as => "all_members"

  get "org_chart" => "main#orgchart", :as => "org_chart"
  get "all_investments" => "main#investments", :as => "all_investments"
  get "all_memories" => "main#memories", :as => "all_memories"
  get "all_retreats" => "main#retreats", :as => "all_retreats"
  get "calendar" => "main#calendar", :as => "calendar"
  get "log_out" => "sessions#destroy", :as => "log_out"
  get "log_in" => "sessions#new", :as => "log_in"
  get "sign_up" => "members#new", :as => "sign_up"

  resources :members

  resources :sessions

  root :to => "sessions#new"

这里编辑的是我的environment.rb文件:

 # Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Newventureclub::Application.initialize!

EDIT2:这是我的application.rb拿出了所有评论

require File.expand_path('../boot', __FILE__)

require 'rails/all'


Bundler.require(:default, Rails.env) if defined?(Bundler)

module Newventureclub
  class Application < Rails::Application

    config.encoding = "utf-8"

    config.filter_parameters += [:password]
  end
end

0 个答案:

没有答案