ankane / ahoy_email

First-party email analytics for Rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ahoy_email PG::InFailedSqlTransaction

gustavobonfim opened this issue · comments

Hi Guys,

I'm having the following problem with ahoy_email

ActiveRecord::StatementInvalid (PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
: INSERT INTO "ahoy_messages" ("token", "to", "mailer", "subject", "content", "utm_source", "utm_medium", "utm_campaign", "lead_id", "content_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id"):

This is what happen in the Mailer. The code is:

def conversion(lead, content)
    @lead = Lead.where(id: lead).first
    @user = @lead
    @content = Content.where(id: content).first
    @url = @content.content_resource.document.url
    track open: true
    track click: true
    track extra: {lead_id: @lead.id, content_id: @content.id}
    from_email_with_name = %("Example" <conteudo@example.com.br>)
    reply_to_email_with_name = %("Example" <conteudo@example.com.br>)
    if @lead.name == "Atualizar"
      to_email_with_name = @lead.email
      mail(from: from_email_with_name,
           reply_to: reply_to_email_with_name,
           to: to_email_with_name,
           subject: "Olá! Segue o link do conteúdo")
    else
      to_email_with_name = %("#{@lead.name}" <#{@lead.email}>)
      mail(from: from_email_with_name,
           reply_to: reply_to_email_with_name,
           to: to_email_with_name,
           subject: "Olá #{@lead.first_name_name}! Segue o link do conteúdo")
    end

Any ideas?

Thanks!

Regards,
Gustavo

Hey @gustavobonfim, I'm not sure, but I don't think it's a problem with Ahoy Email. I'd try Stack Overflow.