views:

32

answers:

1

I have this Class which response to perform to be run by "Resque", I have an error at this line recipient.response = response.body wich is undefined method response=' for #<Hash:0x00000003969da0> I think that because the worker and ActiveRecord can't work together. P.S I already loaded my environment and this class placed in lib directory

Using: Ruby 1.9.2 Rails 3 Resque 1.10.0

class Msg
  def self.perform(message,sender,host, path, recipient)
    message_logger ||= Logger.new("#{Rails.root}/log/message.log")
    response = Net::HTTP.get_response(host, path)
    begin
      recipient.response = response.body
      recipient.sent_at = Time.zone.now
      recipient.save
      # Logging
      log = "Message #{
      message.sent_at}\n\tRespone:\n\t\tBody: #{response.body}\n\t\tCode: #{response.code}\n"
      message_logger.info(log)
    rescue Exception => e
      message_logger.error(e.message + '/n' + e.backtrace.inspect)
    end
  end
end
A: 

That doesn't sound like an issue with resque and activerecord at all. It says the parameter recipient that you passed in was a hash. Where's the code that enqueued the job? You can also take a look a the log output from the worker where you saw that error message to see what the parameters passed into the job were.

Jeremy