代码之家  ›  专栏  ›  技术社区  ›  Augusto Samamé Barrientos

打开跟踪无法与Rails一起使用ahoy\u email gem

  •  0
  • Augusto Samamé Barrientos  · 技术社区  · 6 年前

    发送电子邮件时正在生成消息记录:

    #<Ahoy::Message:0x000055592a4bd3a8
     id: 1,
     token: "AVKoHmuT0OxqaQRpMfNoDjzD3ibUltHL",
     to: "augusto@qounter.com",
     user_type: "User",
     user_id: 6,
     mailer: "UserMailer#welcome_email",
     subject: "Bienvendido al Sistema de Facturación de Megacentro",
     sent_at: Thu, 30 Aug 2018 21:35:44 UTC +00:00,
     opened_at: nil,
     clicked_at: nil,
     comprobante_id: nil>
    

    我的主机配置:

    config.action_mailer.default_url_options = { host: 'megacentro.devtechperu.com' }
    

    发送的电子邮件包含隐藏图像:

    <body>
      ...
      <img alt=3D"" src=3D"http://megacentro.devtechperu.com/ahoy/messages/AVKo=
    HmuT0OxqaQRpMfNoDjzD3ibUltHL/open.gif" width=3D"1" height=3D"1">
    </body>
    </html>
    

    但打开邮件时,打开的地址字段仍然为零

    为了调试,我将相应的URL复制粘贴到浏览器中:

    http://megacentro.devtechperu.com/ahoy/messages/AVKo=
    HmuT0OxqaQRpMfNoDjzD3ibUltHL/open.gif
    

    我总是从服务器得到204响应,这意味着Ahoy控制器没有处理url,因为根据代码,它应该用gif响应。

    可能是Rails最新版本中的一个bug?任何关于调试的建议都将不胜感激。

    I, [2018-08-30T22:11:57.320881 #6906]  INFO -- : [f0912842-0b2c-4314-889b-38d813f1ea24] Started GET "/ahoy/messages/AVKo=HmuT0OxqaQRpMfNoDjzD3ibUlt/open.gif" for 179.6.208.88 at 2018-08-30 22:11:57 +0000
    I, [2018-08-30T22:11:57.321749 #6906]  INFO -- : [f0912842-0b2c-4314-889b-38d813f1ea24] Processing by ApplicationController#raise_not_found as GIF
    I, [2018-08-30T22:11:57.321799 #6906]  INFO -- : [f0912842-0b2c-4314-889b-38d813f1ea24]   Parameters: {"unmatched_route"=>"ahoy/messages/AVKo=HmuT0OxqaQRpMfNoDjzD3ibUlt/open"}
    D, [2018-08-30T22:11:57.608802 #6906] DEBUG -- : [f0912842-0b2c-4314-889b-38d813f1ea24]   User Load (78.3ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 3], ["LIMIT", 1]]
    D, [2018-08-30T22:11:57.609440 #6906] DEBUG -- : [f0912842-0b2c-4314-889b-38d813f1ea24] No route matches ahoy/messages/AVKo=HmuT0OxqaQRpMfNoDjzD3ibUlt/open
    I, [2018-08-30T22:11:57.609619 #6906]  INFO -- : [f0912842-0b2c-4314-889b-38d813f1ea24] Completed 204 No Content in 288ms (ActiveRecord: 159.9ms)
    

    1 回复  |  直到 6 年前
        1
  •  0
  •   Augusto Samamé Barrientos    6 年前

    问题原来是我的两行路由.rb:

    get '*unmatched_route', to: 'application#raise_not_found' unless Rails.env == "development"
    post '*unmatched_route', to: 'application#raise_not_found' unless Rails.env == "development"