rails 生成 rspec:install config/environments/development.rb:1:in `<top (required)>': 未定义的方法 `configure' [英] rails generate rspec:install config/environments/development.rb:1:in `<top (required)>': undefined method `configure'

查看:11
本文介绍了rails 生成 rspec:install config/environments/development.rb:1:in `<top (required)>': 未定义的方法 `configure'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这是我的版本:

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

我正在关注 Hartl Rails 教程并安装 rspec 进行测试.我已经将 gem 'rspec-rails' 添加到我的 gemfile 中,当我运行 rails generate rspec:install,这就是我得到的:

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

这是我的 gemfile:

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

这里是 config/environments/development.rb

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

对这可能是什么有任何想法吗?我继续将 rspec-rails 更新到最新版本 - 想法?

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

推荐答案

在 config/environments/development.rb:

In config/environments/development.rb:

改变

Rails.application.configure do 

SampleApp::Application.configure do

我检查了几个应用程序,这就是我拥有的格式.

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

这篇关于rails 生成 rspec:install config/environments/development.rb:1:in `&lt;top (required)&gt;': 未定义的方法 `configure'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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