I am getting a beautiful error :
failed with NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[] - 3 failed attempts
My Controller:
CardSignup.all.each do |user|
Delayed::Job.enqueue MassEmail.new(user, params[:subject], params[:editor1])
end
mass_email.rb
class MassEmail < Struct.new(:user, :subject, :message)
def perform
Notifier.deliver_email_blast(user, subject, message)
end
end
_form.html.haml
- form_tag admin_email_blast_path do
Subject
%br
= text_field_tag 'subject'
%br
Body
%br
= text_area_tag 'message', '', :name => 'editor1'
%br
= submit_tag 'Send Email', :class => 'button'
:plain
<script type="text/javascript">
CKEDITOR.replace( 'editor1' );
</script>
The problem is because i'm not passing the varis right.. how do I do this proper?
note: It was working perfectly before i implemented delayed_jobs with params[:subject], and params[:editor1], so I have to retain those somehow.
I tried this without Delayed_Jobs, and the MassEmail.new doesn't even leave a backtrace in my log.
I also tried this in my console, and it froze.
There's got to be something wrong with the mass_email.rb or the call in def perform