2015-04-22 61 views
3

在建立一個新的軌道項目中,我所遇到下列問題上rails s命令Rails的錯誤 - 未初始化的常量

john-MacBook-Pro:coffee john$ rails s 
/Users/john/Development/coffee/config/application.rb:10:in `<module:Coffee>': uninitialized constant Coffee::Rails::Application (NameError) 
    from /Users/john/Development/coffee/config/application.rb:9:in `<top (required)>' 
    from /Users/john/.rvm/gems/ruby-2.1.2/gems/railties-4.0.3/lib/rails/commands.rb:74:in `require' 
    from /Users/john/.rvm/gems/ruby-2.1.2/gems/railties-4.0.3/lib/rails/commands.rb:74:in `block in <top (required)>' 
    from /Users/john/.rvm/gems/ruby-2.1.2/gems/railties-4.0.3/lib/rails/commands.rb:71:in `tap' 
    from /Users/john/.rvm/gems/ruby-2.1.2/gems/railties-4.0.3/lib/rails/commands.rb:71:in `<top (required)>' 
    from bin/rails:4:in `require' 
    from bin/rails:4:in `<main>' 

到底是什麼造成這一點,我該如何解決?

感謝您的期待。

application.rb中的文件:

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

require 'rails/all' 

# Require the gems listed in Gemfile, including any gems 
# you've limited to :test, :development, or :production. 
Bundler.require(:default, Rails.env) 

module Coffee 
    class Application < Rails::Application 
    # Settings in config/environments/* take precedence over those specified here. 
    # Application configuration should go into files in config/initializers 
    # -- all .rb files in that directory are automatically loaded. 

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 
    # config.time_zone = 'Central Time (US & Canada)' 

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 
    # config.i18n.default_locale = :de 
    end 
end 
+0

你可以發佈你的application.rb文件嗎? – thaleshcv

+0

希望你在持有代碼的文件夾裏面運行這個命令:) – Milind

+0

添加代碼@thaleshcv – RubyMax

回答

9

你似乎已經叫你的應用程序 '咖啡'。這意味着您在config/application.rb文件中有module Coffee聲明。

Rails使用coffee-rails gem來支持rails應用程序中的咖啡腳本,這也聲明瞭module Coffee

您無意中創建了與您選擇的應用程序名稱的名稱衝突。

+0

業餘的錯誤....謝謝你清理沙德韋爾。 – RubyMax

+4

這就是爲什麼你應該調用每個應用程序'foo' – Yule

相關問題