Hello RoR Folks,
I'm working on document submission web app hosted at site5.com. I've run into an issue that I can't seem to solve. I'm using ActionMailer to send an email any time a document is submitted. My code is bombing out when processing the template for the mailer. Here is an excerpt from the product log file:
ActionView::TemplateError (undefined method `each' for nil:NilClass) on line #19 of app/views/document_mailer/send_upload.rhtml: 16: 17: Submission Authors: 18: <% i = 1 -%> 19: <% @authors.each do |author| -%> 20: <%= i -%>. <%= author.lastname -%>, <%= author.firstname %> 21: <%= author.email %> 22: <% i += 1 %>
Relevant code from the controller: # Find the login, submission and authors associated with this document @login = Login.find(session[:id]) @submission = Submission.find(session[:sub_id]) @authors = Participant.find(:all, :conditions => [ "submission_id = ?", session[:sub_id] ] )
Model: def send_upload(submission, login, authors) @subject = 'New Document Submission' @body = { "login" => login, "submission" => submission, "authors" => authors }
View: Submission Authors: <% i = 1 -%> <% @authors.each do |author| -%> <%= i -%>. <%= author.lastname -%>, <%= author.firstname %> <%= author.email %> <% i += 1 %> <% end -%>
The strange thing is that this code works properly when the app is in development mode. I am a RoR neophite, this being my first Rails app. So hopefully there is a simple step that I am missing. Thanks for your help.