Help! getting a "can't dup NilClass" error and don't know what to do about it


#1

Thanks for any help you can offer.

I am trying to send out a small batch of emails using an http
request. I know it sounds odd. hear me out.

I have loaded a bunch of emails into this table and just want to
slowly work through them. Sort of a poor mans AR:Mailer. But I am
getting a “can’t dup NilClass” when I hit it with a http request.


def message
@reminders = Reminder.find(:all, :order => “created_at DESC”, :limit
=> 5)
for reminder in @reminders
ReminderMailer.deliver_reminder_message(reminder)
reminder.destroy
end
render :nothing => true, :status => 401 # Unauhorized
end


I believe the Mailer class is working right. Although when I remove
the ReminderMailer line the rest of the method works fine.

Please help if I am a million miles off on this and have some
fundamental misunderstanding. Please, please take the time to tell me.


#2

On 12 Nov 2008, at 09:56, eriwright wrote:

Thanks for any help you can offer.

I am trying to send out a small batch of emails using an http
request. I know it sounds odd. hear me out.

I have loaded a bunch of emails into this table and just want to
slowly work through them. Sort of a poor mans AR:Mailer. But I am
getting a “can’t dup NilClass” when I hit it with a http request.

What’s the stack trace ?

Fred


#3

On Nov 12, 2:46 am, Frederick C. removed_email_address@domain.invalid
wrote:

slowly work through them. Sort of a poor mans AR:Mailer. But I am


3KViewDownload
Thank you for responding! here is the stack trace and while I am at it
I have included the ReminderMailer class at the bottom.

Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/
template_error.rb:11:in dup' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/ template_error.rb:11:ininitialize’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:
322:in new' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb: 322:inrender_file’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:
348:in render_without_active_scaffold' /Library/Ruby/Gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/ base.rb:502:inrender’
/Library/Ruby/Gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:494:in render_message' /Library/Ruby/Gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/ base.rb:442:increate!’
/Library/Ruby/Gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:403:in initialize' /Library/Ruby/Gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/ base.rb:352:innew’
/Library/Ruby/Gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:352:in method_missing' app/controllers/reminders_controller.rb:32:inmessage’
app/controllers/reminders_controller.rb:31:in each' app/controllers/reminders_controller.rb:31:inmessage’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:1158:in send' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:1158:inperform_action_without_filters’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:697:in call_filters' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ filters.rb:689:inperform_action_without_benchmark’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
benchmarking.rb:68:in perform_action_without_rescue' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ benchmarking.rb:68:inperform_action_without_rescue’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
rescue.rb:199:in perform_action_without_caching' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ caching.rb:678:inperform_action’
/Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in cache' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ query_cache.rb:8:incache’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
caching.rb:677:in perform_action' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:524:insend’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:524:in process_without_filters' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ filters.rb:685:inprocess_without_session_management_support’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
session_management.rb:123:in process' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:388:inprocess’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in
process' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:insynchronize’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
process' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:inprocess_client’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in each' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:inprocess_client’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:ininitialize’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in new' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:inrun’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
initialize' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:innew’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb: 282:inrun’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
281:in each' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb: 281:inrun’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in
run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb: 212:inrun’
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:489:in load' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:489:inload’
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:342:in new_constants_in' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:489:inload’
/Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/servers/
mongrel.rb:64
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in require' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:342:innew_constants_in’
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in `require’
/Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39

def reminder_message(reminder)
@recipients = reminder.email
@from = “ADMIN EMAIL”
@subject = reminder.subject
@sent_on = Time.now
@content_type = “text/html”
@body = reminder.body
@firstname = reminder.firstname
@lastname = reminder.lastname

end


#4

On 12 Nov 2008, at 16:34, eriwright wrote:

Thank you for responding! here is the stack trace and while I am at it
I have included the ReminderMailer class at the bottom.

I bet you reminder.body is nil.

Fred


#5

On Nov 12, 8:53 am, Frederick C. removed_email_address@domain.invalid
wrote:

I bow to your superior intellect… lol seriously Thank you, thats
exactly what the problem was, you are a gentleman and a scholar