Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails generate rspec:install config/environments/development.rb:1:in `<top (required)>': undefined method `configure'

first, here are my versions:

Greg-Nowickis-MacBook-Pro:sample_app Greg_Nowicki$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-darwin13.1.0]
Greg-Nowickis-MacBook-Pro:sample_app Greg_Nowicki$ rails -v
Rails 4.0.4

I'm following the Hartl Rails tutorial and am install rspec for testing. I have added gem 'rspec-rails' to my gemfile and when I run rails generate rspec:install, this is what I get:

Greg-Nowickis-MacBook-Pro:sample_app Greg_Nowicki$ rails generate rspec:install
    /Users/Greg_Nowicki/workspace/railstutorial/sample_app/config/environments/development.rb:1:in `<top (required)>': undefined method `configure' for #<SampleApp::Application:0x007fcd3a47c138> (NoMethodError)
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/engine.rb:591:in `block (2 levels) in <class:Engine>'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/engine.rb:590:in `each'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/engine.rb:590:in `block in <class:Engine>'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/initializable.rb:30:in `run'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:210:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:209:in `block in each_strongly_connected_component_from'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/initializable.rb:44:in `each'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/initializable.rb:44:in `tsort_each_child'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:203:in `each_strongly_connected_component_from'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from /Users/Greg_Nowicki/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/application.rb:215:in `initialize!'
from /Users/Greg_Nowicki/workspace/railstutorial/sample_app/config/environment.rb:5:in `<top (required)>'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/application.rb:189:in `require'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/application.rb:189:in `require_environment!'
from /Users/Greg_Nowicki/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.4/lib/rails/commands.rb:44:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'

Here is my gemfile:

source 'https://rubygems.org'
ruby '2.0.0'


gem 'rails', '4.0.4'

group :development, :test do
  gem 'sqlite3', '1.3.8'
  gem 'rspec-rails', '~> 3.0.0.beta'
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 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end

and here's config/environments/development.rb

Rails.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

Any thoughts on what this may be? I went ahead and updated rspec-rails to the latest version - thoughts?

like image 974
gregnowicki Avatar asked Apr 24 '14 02:04

gregnowicki


2 Answers

In config/environments/development.rb:

change

Rails.application.configure do 

to

SampleApp::Application.configure do

I checked a couple of my applications, and thats the format I have them.

like image 88
Wally Ali Avatar answered Oct 29 '22 22:10

Wally Ali


Changing development.rb did not help me at all.

However, what did help me is:

$ rvm 2.0.0

BEFORE creating the app with

$ rails new first_app

Note that the Gemfile version was 2.0.0, and not 2.1.1 which is what I had originally, so match the ruby versions before you create your app.

Not sure why this is important.

like image 1
Omar Avatar answered Oct 29 '22 21:10

Omar