Rails 3.2 ActionMailer演示失败

时间:2012-02-01 05:25:56

标签: ruby-on-rails-3 actionmailer

我已经使用rails 3很长一段时间了,但到目前为止我还没有使用过ActionMailer。我跟着guide,并期望它开箱即用。但是,我似乎发现了一些内部rails代码中的错误。不幸的是,我无法找到任何关于此错误的提及,我猜测必须对此进行配置。

我的邮件程序是:

class UserMailer < ActionMailer::Base
  default :from => "notifications@example.com"

  def welcome_email
    @url  = "http://example.com/login"
    mail(:to => "test@example.com", :subject => "Welcome to My Awesome Site")
  end
end

当我尝试使用邮件时,我得到了:

UserMailer.welcome_email
NoMethodError: undefined method `protected_instance_variables=' for ActionController::Base:Class
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.2.1/lib/action_controller/metal/compatibility.rb:22:in `block in <module:Compatibility>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/concern.rb:117:in `class_eval'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/concern.rb:117:in `append_features'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.2.1/lib/action_controller/base.rb:232:in `include'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.2.1/lib/action_controller/base.rb:232:in `<class:Base>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.2.1/lib/action_controller/base.rb:171:in `<module:ActionController>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.2.1/lib/action_controller/base.rb:3:in `<top (required)>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.2.1/lib/action_view/test_case.rb:11:in `<class:TestCase>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.2.1/lib/action_view/test_case.rb:10:in `<module:ActionView>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.2.1/lib/action_view/test_case.rb:8:in `<top (required)>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/prototype-rails-3.2.1/lib/prototype-rails/on_load_action_view.rb:17:in `<top (required)>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:234:in `block in load_dependency'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:234:in `load_dependency'
... 23 levels...
    from /users/user/Documents/element/app/mailers/user_mailer.rb:1:in `<top (required)>'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:469:in `load'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:469:in `block in load_file'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:468:in `load_file'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:353:in `require_or_load'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:502:in `load_missing_constant'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:192:in `block in const_missing'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:190:in `each'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:190:in `const_missing'
    from (irb):1
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.2.1/lib/rails/commands/console.rb:47:in `start'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.2.1/lib/rails/commands/console.rb:8:in `start'
    from /Users/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.2.1/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我使用的是rails 3.2.1。我看到一些提及protected_instance_variables =被弃用,这可能解释了为什么它没有为ActionController :: Base定义。但是,这似乎是一个铁轨错误,我想象ActionMailer已经过很好的测试。有人有什么想法吗?

由于

1 个答案:

答案 0 :(得分:1)

我在启动rails 3.2.1应用程序时遇到了类似的错误 - 删除了prototype-rails gem为我解决了这个问题。

当然我碰巧使用原型,所以现在有一个不同的问题需要解决。