我正在尝试禁用我在我的应用程序中没有使用的部分rails,例如ActionMailer。 Ib我的application.rb,我做了以下更改
require "action_controller/railtie"
require "action_mailer/railtie"
#require 'rails/all'
我的应用程序运行正常。现在,当我去评论“require”action_mailer / railtie“'行时,我收到以下错误。我没有安装任何邮件,所以发生了什么?
由于
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/railtie/configuration.rb:77:in `method_missing': undefined method `action_mailer' for #<Rails::Application::Configuration:0x00000002c337f8> (NoMethodError)
from /home/test/shipped/deluxe/deluxe/config/environments/development.rb:18:in `block in <top (required)>'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/application.rb:47:in `class_eval'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/application.rb:47:in `configure'
from /home/test/shipped/deluxe/deluxe/config/environments/development.rb:1:in `<top (required)>'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `block in require'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/application/bootstrap.rb:11:in `block in <module:Bootstrap>'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `block in run_initializers'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /home/test/shipped/deluxe/deluxe/config/environment.rb:6:in `<top (required)>'
from /home/test/shipped/deluxe/deluxe/config.ru:3:in `require'
from /home/test/shipped/deluxe/deluxe/config.ru:3:in `block in <main>'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
from /home/test/shipped/deluxe/deluxe/config.ru:1:in `new'
from /home/test/shipped/deluxe/deluxe/config.ru:1:in `<main>'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/builder.rb:35:in `eval'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/builder.rb:35:in `parse_file'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/server.rb:162:in `app'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/server.rb:248:in `wrapped_app'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/server.rb:213:in `start'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/server.rb:65:in `start'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:30:in `block in <top (required)>'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
答案 0 :(得分:6)
注意,在Rails 3中不推荐使用config.frameworks!
您遇到的错误来自文件development.rb的#18行:
config.action_mailer.raise_delivery_errors = false
由于您不再需要它,因此未定义config.action_mailer。你只需要对该行进行评论就可以了。
答案 1 :(得分:1)
在application.rb
中config.frameworks -= [:action_mailer]