Rake task not able to send mail by requiring 'roo' Rails

216 views Asked by At

I am writing a rake task for importing data from Csv, Xls and Xlsx for with Roo '1.9.1' ruby '1.8.7' and Rails '2.3.18'.

It works fine with all the data import and processing.

At the top of the file I have require 'iconv' require 'roo'

I am calling

spreadsheet, format = 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

But when I try send a notfication mail for the created residents by using,

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

I will get error like this NameError: uninitialized constant ActionMailer::Quoting::Encoding

When I comment @subject in mailer method I will get error like this

ActionView::TemplateError: undefined method `encoding' for # from In app/views/notifications/resident_subscription_notification_rake.html.erb

May I know where I am going wrong. Thanks

0

There are 0 answers