2012-02-01 138 views
2

我已經使用rails 3很長一段時間了,但是我現在還沒有使用ActionMailer。我跟着guide,並預計它可以開箱即用。但是,似乎我碰到了深入內部導軌代碼的一些錯誤。不幸的是,我找不到任何提及這個錯誤的信息,我猜測它必須做到配置。Rails 3.2 ActionMailer演示失敗

我的郵件類是:

class UserMailer < ActionMailer::Base 
    default :from => "[email protected]" 

    def welcome_email 
    @url = "http://example.com/login" 
    mail(:to => "[email protected]", :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>' 

我使用的鐵軌3.2.1。我看到一些提及protected_instance_variables =被棄用的情況,這也許可以解釋爲什麼它沒有爲ActionController :: Base定義。但是,這看起來像是一個軌道錯誤,我會想象,ActionMailer已經過很好的測試。有人有主意嗎?

感謝

+0

同樣的問題。任何解決方案,但? – Jan 2012-03-07 11:49:02

回答

1

我曾經歷過上啓動我的Rails 3.2.1應用類似的錯誤 - 移除了原型軌寶石解決了這個問題對我來說。

當然,我碰巧使用的是原型,所以現在有一個不同的問題需要解決。