Rails4.2 Ahoy电子邮件-未在消息模型中设置用户数据

时间:2019-04-11 01:02:54

标签: ruby-on-rails ruby-on-rails-4 ahoy

我已经成功设置了Ahoy Email,并且运行良好,并且可以轻松跟踪我的访问,打开和点击的情况。

我唯一遇到麻烦的地方是在我的Ahoy::Message模型中设置用户数据。我进行了调试,还可以看到属性user_id和{{ 1}}易于设置,但不能插入数据库。

我在user_type中调试

initializers/ahoy_email.rb

从上面可以看到,我正在获取用户,但未在下面显示的实际插入查询中设置它。

 AhoyEmail.track_method = lambda do |data|
   Rails.logger.info " =======TRACK AHOY EMAILS=============== "
   Rails.logger.info data
 end



=====debug value=====with user_id and user_type along with user object and devise attributes
==== other data is removed for more clarity
{:mailer=>"BusinessMailer#notify_about_new_message", :extra=>{}, :user=>#<User id: 145, email: "user_1542307802tbzyjlbl@gmail.com",xxxxxxxxx all devise specific attributes..>, :user_type=>"User", :user_id=>145, :token=>"cccxxxxxxxxxxxtokenxxxxxxxxx", :message=>#<Mail::XXXXXXXXXXX}

我还尝试在 ##where is the user data?#### SQL (3.3ms) INSERT INTO "ahoy_messages" ("to", "mailer", "subject", "token", "sent_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["to", "USER_1542307802TBZYJLBL@gmail.com"], ["mailer", "BusinessMailer#notify_about_new_message"], ["subject", "New Messagexxxxx"], ["token", "CEls3LuSU5ohnmzoXQTkTbqbWPt3IlJF"], ["sent_at", "2019-04-11 00:40:55.846351"]] 文件中添加@user,但仍然相同

mailer.rb

如果有人可以在这里放点灯,将不胜感激:)

谢谢。

0 个答案:

没有答案