method_missing':undefined方法`action_mailer'在rspec期间:安装

时间:2014-03-20 23:33:07

标签: ruby-on-rails ruby rspec

我一直遇到问题一天。我在谷歌找到的任何东西到目前为止都没有。请帮忙。

我在rspec:install命令期间收到Method not found Error。我是一个新手试图跟踪rails教程,我不能使用确切的Gemfile,因为一些Gems已经过时了。

由于

*bash-3.2$ rails generate rspec:install
/Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `action_mailer' for #<Rails::Application::Configuration:0x007fe2c4080670> (NoMethodError)
    from /Users/user22/Projects/rails_projects/sample_app/config/environments/development.rb:17:in `block in <top (required)>'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/railtie/configurable.rb:24:in `class_eval'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/railtie/configurable.rb:24:in `configure'
    from /Users/user22/Projects/rails_projects/sample_app/config/environments/development.rb:1:in `<top (required)>'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/engine.rb:591:in `block (2 levels) in <class:Engine>'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/engine.rb:590:in `each'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/engine.rb:590:in `block in <class:Engine>'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/initializable.rb:30:in `run'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/initializable.rb:44:in `each'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:411:in `call'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `each'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `call'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
    from /Users/user22/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/application.rb:215:in `initialize!'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/user22/Projects/rails_projects/sample_app/config/environment.rb:5:in `<top (required)>'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/application.rb:189:in `require'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/application.rb:189:in `require_environment!'
    from /Users/user22/.rvm/gems/ruby-2.1.1@global/gems/railties-4.0.4/lib/rails/commands.rb:44:in `<top (required)>*


bash-3.2$ cat Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.0.4)
      actionpack (= 4.0.4)
      mail (~> 2.5.4)
    actionpack (4.0.4)
      activesupport (= 4.0.4)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.4)
      activesupport (= 4.0.4)
      builder (~> 3.1.0)
    activerecord (4.0.4)
      activemodel (= 4.0.4)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.4)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.4)
      i18n (~> 0.6, >= 0.6.9)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    arel (4.0.2)
    atomic (1.1.16)
    builder (3.1.4)
    capybara (2.2.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    coffee-rails (4.0.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.7.0)
    diff-lcs (1.2.5)
    erubis (2.7.0)
    execjs (2.0.2)
    hike (1.2.3)
    i18n (0.6.9)
    jquery-rails (3.1.0)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.1)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.25.1)
    mini_portile (0.5.2)
    minitest (4.7.5)
    multi_json (1.9.2)
    nokogiri (1.6.1)
      mini_portile (~> 0.5.0)
    pg (0.17.1)
    polyglot (0.3.4)
    rack (1.5.2)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.0.4)
      actionmailer (= 4.0.4)
      actionpack (= 4.0.4)
      activerecord (= 4.0.4)
      activesupport (= 4.0.4)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.4)
      sprockets-rails (~> 2.0.0)
    railties (4.0.4)
      actionpack (= 4.0.4)
      activesupport (= 4.0.4)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.1.1)
    rspec-core (2.14.8)
    rspec-expectations (2.14.5)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.14.6)
    rspec-rails (2.14.1)
      actionpack (>= 3.0)
      activemodel (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    sass (3.3.3)
    sass-rails (4.0.1)
      railties (>= 4.0.0, < 5.0)
      sass (>= 3.1.10)
      sprockets-rails (~> 2.0.0)
    sprockets (2.12.0)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    sqlite3 (1.3.9)
    thor (0.18.1)
    thread_safe (0.3.0)
      atomic (>= 1.1.7, < 2)
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    turbolinks (2.2.1)
      coffee-rails
    tzinfo (0.3.39)
    uglifier (2.5.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  actionmailer (~> 4.0.4)
  capybara
  coffee-rails
  jquery-rails
  pg
  rails (~> 4.0.3)
  rspec-rails
  sass-rails
  sqlite3
  turbolinks
  uglifier

编辑: 在下面回答几个问题。 @Wayne: 你的包很完整! 未安装组生产中的宝石。 使用bundle show [gemname]查看捆绑的gem的安装位置。

@Taryn

来源&#39; https://rubygems.org&#39; 宝石&#39; rails&#39;,&#39;〜&gt; 4.0.3&#39; group:开发,:test do   gem&#39; sqlite3&#39;   宝石&#34; rspec-rails&#34; 端

Gems仅用于资产而非必需

默认情况下,在生产环境中

组:资产   宝石&#39; sass-rails&#39;   gem&#39; coffee-rails&#39;   宝石&#39; uglifier&#39; 结束 gem&#39; jquery-rails&#39; gem&#34; actionmailer&#34;,&#34;〜&gt; 4.0.4&#34; 组:测试做   宝石&#39;水豚&#39; gem&#34; actionmailer&#34;,&#34;〜&gt; 4.0.4&#34; 结束 组:生产做   宝石&#39;&#39;   宝石&#39; turbolinks&#39; 端

@Andreas: 很好的一点。我有下面的第16行和第17行。

不在乎邮件是否无法发送。

config.action_mailer.raise_delivery_errors = false

根据你的评论,我评论了#17并重新安装了它,它运行正常。我没有对该项目进行任何更改。它是使用rails生成的(完全)。我认为通过评论#17我可能会错过一个功能。我可以通过一种方式修复它而不评论正确吗?

谢谢大家。

0 个答案:

没有答案