简体   繁体   English

是否可以在Rails 3 application.rb中“卸载” ActionMailer?

[英]Is it possible to 'unload' ActionMailer in Rails 3 application.rb?

I am trying to disable the parts of rails that i'm not using in my application, such as ActionMailer. 我正在尝试禁用我的应用程序中未使用的rails部分,例如ActionMailer。 Ib my application.rb, I made the following change ib我的application.rb,我做了以下更改

require "action_controller/railtie"
require "action_mailer/railtie"
#require 'rails/all'

And my app works fine. 而且我的应用程序运行正常。 Now when I go and comment out the 'require "action_mailer/railtie"' line, I get the following error. 现在,当我注释掉'require“ action_mailer / railtie”'行时,出现以下错误。 I don't haveany mailers installed, so what's going on? 我没有安装任何邮件程序,这是怎么回事?

Thanks 谢谢

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

Be careful, config.frameworks is deprecated in Rails 3! 注意,Rails 3不推荐使用config.frameworks!

The error you've got is coming from the #18 line of the file development.rb : 您遇到的错误来自文件development.rb的#18行:

config.action_mailer.raise_delivery_errors = false

Since you do not require it anymore, config.action_mailer is undefined. 由于不再需要它,因此config.action_mailer是未定义的。 You just have to comment the line and you will be fine. 您只需要在评论行中就可以了。

在application.rb中

config.frameworks -= [:action_mailer]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM