启动 Rails 服务器时出错:未定义的方法“配置" [英] Error launching Rails server: undefined method 'configure'

查看:23
本文介绍了启动 Rails 服务器时出错:未定义的方法“配置"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Rails 新手,正在学习 Hartl 的教程.一切都很好,直到我尝试第二次完成本教程并创建了另一个尝试使用最新版本 rails 的项目.当我尝试从应用程序文件夹加载 rails server 时,我收到以下错误.

I'm new to rails and working through Hartl's tutorial. Everything was fine until I tried to do the tutorial a second time and created another project trying to use the latest version of rails. When I try to load the rails server from the app folder I get the following error.

$ rails s
=> Booting WEBrick
=> Rails 4.0.4 application starting in development on
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/sierra/Desktop/sample_app_2/config/environments/development.rb:1:in
  `<top (required)>': undefined method `configure' for
  #<SampleApp2::Application:0x00000101a74610> (NoMethodError)

我的 Gemfile 直接来自 Hartl 教程:

My Gemfile is directly from the Hartl tutorial:

source 'https://rubygems.org'
ruby '2.1.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.4'

group :development, :test do
  gem 'sqlite3', '1.3.8'
  gem 'rspec-rails', '2.13.1'
end

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'rails_12factor', '0.0.2'
end

推荐答案

我按照以下步骤解决了.

I resolved it by doing following step.

步骤 1:转到 Project_Root_Directory/config/environment/development.rb

Step 1: go to Project_Root_Directory/config/environment/development.rb

改变这一行

Rails.application.configure do

Your_Rails_Application_Folder_name::Application.configure do

例如,我的 rails 项目文件夹名称是Spree_demo",因此在以下行中使用 Your_Rails_Application_Folder_name:

For example my rails project folder name is 'Spree_demo' so Your_Rails_Application_Folder_name in the following line:

Your_Rails_Application_Folder_name::Application.configure do

将被替换为

SpreeDemo::Application.configure do

注意:在您的应用程序文件夹名称中看到下划线,它会被删除.

希望对你们有用.

这篇关于启动 Rails 服务器时出错:未定义的方法“配置"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆