启动Rails服务器时出错:undefined method'configure'

编程入门 行业动态 更新时间:2024-10-24 14:25:11
本文介绍了启动Rails服务器时出错:undefined method'configure'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚接触rails,并通过 Hartl的教程工作。一切都很好,直到我第二次尝试教程并创建另一个试图使用最新版本的rails的项目。当我尝试从应用程序文件夹加载 rails server 时,出现以下错误。

$ rails s =>引导WEBrick => Rails 4.0.4应用程序从开发 =>开始为更多启动选项运行`rails server -h` => Ctrl-C关闭服务器退出 /Users/sierra/Desktop/sample_app_2/config/environments/development.rb:1:in `< top(required)>': #未定义的方法`configure'< SampleApp2 :: Application:0x00000101a74610> (NoMethodError)

我的Gemfile直接来自Hartl教程:

source'rubygems' 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' 组:doc do gem'sdoc','0.3.20',要求:false 结束 group:production do gem'rails_12factor','0.0.2' end

第1步:转至Project_Root_Directory / config / environment / development .rb

更改此行

Rails.application.configure do

Your_Rails_Application_Folder_name :: Application.configure do

例如我的rails项目文件夹名称是'Spree_demo 'so Your_Rails_Application_Folder_name :

Your_Rails_Application_Folder_name :: Application.configure do

将被替换为

SpreeDemo :: Application.configure do

注意:请参阅应用程序文件夹中的下划线名称被删除。

希望它适合你们。

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)

My Gemfile is directly from the Hartl tutorial:

source 'rubygems' 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.

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

Change this line

Rails.application.configure do

To

Your_Rails_Application_Folder_name::Application.configure do

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

will be replaced as

SpreeDemo::Application.configure do

Note: See underscore in your application folder name it gets removed.

Hope it works for you guys.

更多推荐

启动Rails服务器时出错:undefined method'configure'

本文发布于:2023-11-16 20:49:18,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   undefined   Rails   configure   method

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!