无法弄清楚如何更新邮箱 is

编程入门 行业动态 更新时间:2024-10-25 09:29:04
本文介绍了无法弄清楚如何更新邮箱 is_read的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用邮箱管理器 gem 并且我正在尝试使用它,以便在我查看对话后(通过访问对话#show),我希望收据的 is_read 属性变为真.但是,在我发送回复之前,该属性不会变为真.我尝试使用以下行:

I am using the mailboxer gem and I am trying to make it so that after i look at a conversation (by accessing conversations#show), I want the is_read attribute of the receipt to turn true. However, the attribute will not turn true until I send a reply. I tried using the following line:

receipt.update_attributes(is_read: true)

但返回以下错误:

Error (ActiveRecord::ReadOnlyRecord)

我想我理解错误.我认为这是说该属性只能读取而不能更新.我的问题是,如果我转到对话#show 页面,如何实现让 is_Read 变为真的功能?

I think I understand the error. I think it is saying that the attribute can only be read and not updated. My question is, how do I implement the functionality to have is_Read turn true if i go to the conversations#show page?

推荐答案

不要更新 is_read 属性试试这个

Instead of updating the is_read attribute try this

#conversations_controller.rb def show @receipts = mailbox.receipts_for(conversation).not_trash @receipts.mark_as_read end private def mailbox @mailbox ||= current_user.mailbox end def conversation @conversation ||= mailbox.conversations.find(params[:id]) end

您还可以将整个对话标记为已读

You can also mark a entire conversation as read with

conversation.mark_as_read(current_user)

更多推荐

无法弄清楚如何更新邮箱 is

本文发布于:2023-11-27 02:57:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636282.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弄清楚   邮箱

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!