我刚接触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 doTo
Your_Rails_Application_Folder_name::Application.configure doFor 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 dowill be replaced as
SpreeDemo::Application.configure doNote: See underscore in your application folder name it gets removed.
Hope it works for you guys.
更多推荐
启动Rails服务器时出错:undefined method'configure'
发布评论