耙子任务无法通过要求“roo”来发送邮件。轨道

时间:2014-12-04 13:52:07

标签: actionmailer ruby-on-rails-2 ruby-1.8.7 roo

我正在编写一个rake任务,用于从Csv,Xls和Xlsx导入数据,用于Roo' 1.9.1'红宝石1.8.7'和Rails' 2.3.18'。

它适用于所有数据导入和处理。

我在文件的顶部 要求' iconv' 要求' 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:未定义的方法`encoding&#39;为# 来自app / views / notifications / resident_subscription_notification_rake.html.erb

我可以知道我哪里出错了。感谢

0 个答案:

没有答案