gpt4 book ai didi

ruby-on-rails - Rails 错误 - 未初始化的常量

转载 作者:数据小太阳 更新时间:2023-10-29 07:44:56 25 4
gpt4 key购买 nike

在设置新的 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>'

到底是什么原因造成的,我该如何解决?

感谢您的关注。

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

最佳答案

您似乎将您的应用程序称为“咖啡”。这意味着您在 config/application.rb 文件中有一个 module Coffee 声明。

Rails 使用 coffee-rails gem 在 Rails 应用程序中支持 CoffeeScript ,这也声明了一个 module Coffee

您无意中创建了与您选择的应用程序名称的名称冲突。

关于ruby-on-rails - Rails 错误 - 未初始化的常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29799317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com