title: How do I debug this 'no method' error in ruby on rails?
body: <p>I get the following error:</p>
  
  <pre><code>Delayed::Job SomeMailJob# (NoMethodError) "undefined method `subject' for #&lt;YAML::Object:0x2b0a191f4c78&gt;"
  </code></pre>
  
  <p>This comes from the following code which references the SombMailJob above:</p>
  
  <pre><code> class SomeMailJob &lt; Struct.new(:contact, :contact_email) 
     def perform
       OutboundMailer.deliver_campaign_email(contact,contact_email)
     end
   end
  </code></pre>
  
  <p>Here is the mailer:</p>
  
  <pre><code>class OutboundMailer &lt; Postage::Mailer 
  
    def campaign_email(contact,email)
      subject    email.subject
      recipients contact.email
      from       'me.com&gt;'
      sent_on    Date.today
  
      body       :email =&gt; email
    end
  </code></pre>
  
  <p>This is the cron task that invokes the mailer:</p>
  
  <pre><code>Contact.all.each do |contact|
    email = contact.email_today #email_today is a contact method returning email object if &lt;= today
  
    unless contact.email_today == "none" || email.nil?
      puts "contact info inside cron job"
      puts contact.first_name
      puts email.days
      puts contact.date_entered
      puts contact.colleagues
      puts "substituted subject:"
      puts email.substituted_subject(contact,contact.colleagues)
  
      # create the Contact Email object that gets created and sent
  
      contact_email = ContactEmail.new
      contact_email.contact_id = contact.id
      contact_email.email_id = email.id
  
      contact_email.subject = email.substituted_subject(contact,contact.colleagues)
  
  
      puts contact_email.subject
  
      contact_email.date_sent = Date.today
      contact_email.date_created = Date.today
  
      contact_email.body = email.substituted_message(contact, contact.colleagues)
  
      contact_email.status = "sent" 
  
      #Delayed::Job.enqueue OutboundMailer.deliver_campaign_email(contact,contact_email)
      Delayed::Job.enqueue SomeMailJob.new(contact,contact_email)
  
      contact_email.save #now save the record
  </code></pre>
  
  <p><em>Question: why am I getting this error?  I don't even know what the object is because it is coming up with the  code, so I can't really drill-down further to debug.</em></p>