Rails error - Uninitialized constant

After creating a new rails project, I faced the following issues in the team 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 to fix it?

Thanks for watching.

Application.rb file:

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

      

+3


source to share


1 answer


You seem to have named your app "coffee". This means that you have an ad module Coffee

in your file config/application.rb

.

Rails uses the coffee-rails gem to support the coffee script in the rails app, and it declares that as well module Coffee

.



You accidentally created a naming conflict with your choice of app name.

+9


source







All Articles