I am having trouble with one of my notifications. For some reason it doesn't seem to even try and send. I have notifications in other locations and they send just fine.
Here is the code that should call the notification:
if @post.save # We want to set the updated_at time if the post was saved # Updating the number of replies would be good too. Conversation.update(params[:conversation_id], { :updated_at => Time.now, :replies => replies }) User.update(session[:user].id, { :num_posts => (session[:user].num_posts += 1) })
conv_owner = Conversation.find(params[:conversation_id]).user_id owner_email = User.find(conv_owner).email Notifications.deliver_new_thread_post(owner_email, params[:conversation_id])
if session[:conversation] redirect_to :controller => 'conversations', :action => 'show', :id => session[:conversation] end
Here is the Notification method:
def new_thread_post(to, conversation_id, sent_at = Time.now) @subject = "Someone has posted to your thread" @body['conversation_url'] = "http://happyleper.com/conversations/ show/#{conversation_id}" @recipients = to @from = 'info@happyleper.com' @sent_on = sent_at @headers = {} end
And the template:
There has been a reply to your thread at:
<%= @conversation_url %>
When I make a thread post the code inside the if is run but I don't see anything in the logs about the notification sending or failing. There is no postfix activity in /var/log/messages though so it would appear that it doesn't run or dies before trying to send the email.
Any ideas?
Thanks.