【发布时间】:2013-05-01 06:07:42
【问题描述】:
我正在尝试将应用程序从 rails 2.3 升级到 3.0.6
rails 2.3 中有以下代码
class MessageSender < ActionMailer::Base
def send_message(subject,to,from,body,respondent = nil, content_type = 'text/plain')
@content_type = content_type
@subject = subject
@recipients = to
@from = from
# @sent_on = Time.now
@body = {:body_text => body}
end
end
升级过程中代码修改如下
class MessageSender < ActionMailer::Base
def send_message(subjet,to,from,body,respondent = nil,content_type='text/plain')
mail(:to => to, :subject => subject, :from => from, :body => body, :content_type => content_type)
end
end
参考这个著名的blog 关于在rails 3.0 中使用ActionMailer
最后运行rake rails:upgrade:check(检查rails 3 不兼容的功能),它显示
Old ActionMailer class API
You're using the old API in a mailer class.
More information: http://lindsaar.net/2010/1/26/new-actionmailer-api
The culprits:
- app/models/message_sender.rb
(即)它说我仍在使用 Old API
有人能解释一下我在这里缺少什么吗?
或者有没有其他方法可以消除“您在邮件类中使用旧 API”的错误?
仅供参考:宝石已更新,环境为 ruby 1.8.7,rails 3.0.6
【问题讨论】:
-
也许这是因为您的邮件在
app/models而不是app/mailers? -
@Lucas 尝试将其移至
app/mailers但结果相同
标签: ruby-on-rails ruby-on-rails-3 gem actionmailer rails-3-upgrade