运行命令rails server时获取NameError

时间:2014-07-08 16:39:42

标签: ruby-on-rails ruby

我是Ruby的新手,并且正在关注Michael Hartl的教程。我还在第1章。

它说

    undefined local variable or method 'first_app' for main:Object (NameError)

位于我的development.rb第1行。

    Firstapp::Application.configure do
    # Settings specified here will take precedence over those in config/application.rb.

    # In the development environment your application's code is reloaded on
    # every request. This slows down response time but is perfect for development
    # since you don't have to restart the web server when you make code changes.
    config.cache_classes = false

    # Do not eager load code on boot.
    config.eager_load = false

    # Show full error reports and disable caching.
    config.consider_all_requests_local       = true
    config.action_controller.perform_caching = false

    # Don't care if the mailer can't send.
    config.action_mailer.raise_delivery_errors = false

    # Print deprecation notices to the Rails logger.
    config.active_support.deprecation = :log

    # Raise an error on page load if there are pending migrations.
    config.active_record.migration_error = :page_load

    # Debug mode disables concatenation and preprocessing of assets.
    # This option may cause significant delays in view rendering with a large
    # number of complex assets.
    config.assets.debug = true

    # Adds additional error checking when serving assets at runtime.
    # Checks for improperly declared sprockets dependencies.
    # Raises helpful error messages.
    config.assets.raise_runtime_errors = true

    # Raises error for missing translations
    # config.action_view.raise_on_missing_translations = true
    end

我在StackOverflow上没有解决方案的其他问题。其中一些需要更改我的应用名称

    Rails.application.configure do

    First_app::Application.configure do 

没有解决任何问题。哦,如果有帮助,我会使用Windows。

2 个答案:

答案 0 :(得分:2)

运行rails new命令时,应该正确设置应用程序的名称。我想发生了什么事情你可能是rails new firstapp而不是rails new first_app。将First_app::Application.configure do更改为FirstApp::Application.configure do。您也应该在项目中搜索Firstapp或First_App并进行更改。

答案 1 :(得分:1)

这显然与我的Gem文件有关。我没有对此进行编辑而不管它,应用程序最终编译没有任何错误。我认为它与SQLite3 gem有关,我没有正确地对待版本。