我正在为 Roo '1.9.1' ruby '1.8.7' 和 Rails '2.3.18' 编写一个 rake 任务,用于从 Csv、Xls 和 Xlsx 导入数据。
它适用于所有数据导入和处理。
在文件的顶部我有 require 'iconv' require 'roo'
我打电话
电子表格,格式 = open_spreadsheet(file_path, file_name)
def open_spreadsheet file_path, file_name
format, file = "", ""
case File.extname(file_name)
when ".xls"
format = "xls"
file = Excel.new(file_path, nil, :ignore)
when ".xlsx"
format = "xlsx"
file = Excelx.new(file_path, nil, :ignore)
else raise "Unknown file type: #{file_name}"
end
return file, format
end
但是当我尝试通过使用为创建的居民发送通知邮件时,
Notifications.deliver_resident_subscription_notification_rake(@subscription, resident)
def resident_subscription_notification_rake(subscription, resident)
# I18n.locale = "some text"
@subject = "Test Subject"
@body[:subscription] = subscription
@body[:resident] = subscription.resident
@body[:provider] = 'Test Provider'
@body[:recipient] = 'Test Recipient'
@body[:join_url] = subscriber_join_url(
:token => subscription.resident_update_recipient.invitation_code,
:host => APP_CONFIG['site']['root_url']
)
@recipients = 'Test Emails'
@from = "#{subscription.resident.provider.name} <#{subscription.resident.provider.reply_email_address}>"
@headers['x-custom-ip-tag'] = APP_CONFIG['mailer']['custom_ip_tag']
@sent_on = Time.now
end
我会收到这样的错误 NameError: uninitialized constant ActionMailer::Quoting::Encoding
当我在邮件方法中评论@subject时,我会收到这样的错误
ActionView::TemplateError: undefined method `encoding' for # from In app/views/notifications/resident_subscription_notification_rake.html.erb
我可以知道我哪里出错了。谢谢