Error launching Rails server: undefined method 'configure'

snorkelzebra picture snorkelzebra · Apr 10, 2014 · Viewed 22.9k times · Source

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 '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

Answer

Muhammad Ateq Ejaz picture Muhammad Ateq Ejaz · Apr 10, 2014

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.