[英]Rails Error - Uninitialized Constant
Upon setting up a new rails project I have come across the following issues on the rails s
command 在设置新的rails项目时,我在rails s
命令中遇到了以下问题
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>'
What exactly is causing this and how do I fix it? 究竟是什么造成了这种情况,我该如何解决?
Thanks for looking. 谢谢你的期待。
Application.rb file: 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
You seem to have called your application 'coffee'. 您似乎已将您的应用程序称为“咖啡”。 This means that you have a module Coffee
declaration in your config/application.rb
file. 这意味着您的config/application.rb
文件中有一个module Coffee
声明。
Rails uses the coffee-rails gem to support coffee script in a rails application and this also declares a module Coffee
. Rails使用coffee-rails gem来支持rails应用程序中的coffee脚本,这也声明了一个module Coffee
。
You have inadvertently created a name clash with your choice of application name. 您无意中使用您选择的应用程序名称创建了名称冲突。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.