Tag: 通知

使用MessageClicks表跟踪已读/未读的用户消息?

我正在尝试为我的应用程序的用户实现一个简单的收件箱系统 ,以便可以相互发送基本消息 – 就像在许多论坛系统中一样。 如果User has_many :messages ,我如何跟踪并通知用户自上次阅读以来未读的消息? 我认为点击Messages屏幕的链接需要记录在一个单独的表( MessagesClicks )中。 这是最好的方法吗? 那么我检查MessagesClicks表以查看自上次链接被点击以来是否有任何新消息 – 基于last_clicked或updated_at字段 。

Ubuntu虚拟环境上的自动测试通知

我无法让Rails自动测试通知在Engine Yard Vagrant环境中工作。 在Mac上,我通常通过Growl收到通知。 但是,在运行Ubuntu的虚拟环境中不起作用。 我尝试运行Linux通知设置,如libnotify + autotest-notification,但是我收到以下错误: libnotify-Message: Unable to get session bus: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed. ** (notify-send:1004): CRITICAL **: dbus_g_proxy_connect_signal: assertion `DBUS_IS_G_PROXY (proxy)’ failed ** (notify-send:1004): CRITICAL **: dbus_g_proxy_connect_signal: assertion `DBUS_IS_G_PROXY (proxy)’ failed ** (notify-send:1004): CRITICAL **: dbus_g_proxy_call: assertion `DBUS_IS_G_PROXY (proxy)’ failed 另一条路径是让Growl远程接收通知,但我甚至不知道从哪里开始…… 有什么建议?

如何增加rails gem中的字段?

我收到这个错误: SQL (31.1ms) INSERT INTO “read_marks” (“readable_id”, “readable_type”, “timestamp”, “user_id”) VALUES ($1, $2, $3, $4) RETURNING “id” [[“readable_id”, nil], [“readable_type”, “PublicActivity::ORM::ActiveRecord::Activity”], [“timestamp”, Mon, 04 Mar 2013 03:29:52 UTC +00:00], [“user_id”, 2]] PG::Error: ERROR: value too long for type character varying(20) 因为“readable_type”只包含20个字符,所以我传入“PublicActivity :: ORM :: ActiveRecord :: Activity”。 这与使用gem未读的public_activity (显然解决了问题,但没有说明如何(见他的底部更新))相同的问题

Rails 5 – 如何以实时方式发送通知?

在rails 5中,我试图以实时方式发送通知。 我已经提到了http://jameshuynh.com/rails/react%20js/chat/2017/07/30/build-chat-using-react-js-and-rails-action-cable/ 但我已经有一些方法也会这样做。 根据此方法,通知应基于user_id动态发送。 甚至频道取决于user_id。 在react,header.jsx文件中, import ActionCable from ‘actioncable’; export default class Header extends React.Component { cable = ActionCable.createConsumer(‘ws://localhost:3000/cable’); componentDidMount() { HttpService.get(‘/api/v1/notifications’, this.getNotificationsSuccess); let that = this; this.cable.subscriptions.create(“NotificationsChannel”, { user_id: this.state.currentUser.id, connected: function () { // Timeout here is needed to make sure Subscription // is setup properly, before we do any actions. […]

Rails通知系统

我需要为我正在处理的应用程序创建一个类似facebook的通知系统。 我想知道你们有什么建议去做这件事? 如果可能的话,我想避免使用数据库进行通知,如果这是可行的,我很想知道如何。 提前致谢

Rails 4 – Toaster通知而不是Flash通知

我正在使用这个库,( https://github.com/CodeSeven/toastr ),我正在尝试将我的Flash通知推送到Toastr为我提供的javascript函数。 如何针对每个错误或通知调用此函数? 这是用于制作烤面包机通知的方法之一: toastr.warning(‘This is a warning!’) 我尝试在ApplicationController中创建一个方法,看看我是否可以在CanCan的默认错误上调用该方法。 我有各种版本的方法,但都没有。 def toast(type, text) #if Logic here for various errors/notifications respond_to do |format| format.js { render action: “toastr.warning(#{text})”, layout: false} end end def toast(type, text) #if Logic here for various errors/notifications “toastr.warning(#{text})” end 然后我尝试在CanCan块中使用此方法: rescue_from CanCan::AccessDenied do |exception| toast :error, exception.message redirect_to root_url end 我认为这是可能的,但我只是不确定如何实现它。 […]

通知ala Facebook(数据库实施)

我想知道Facebook如何实现他们的通知系统,因为我正在寻找类似的东西。 FooBar评论了你的状态 Red1,Green2和Blue3对你的照片发表了评论 MegaMan和另外5人对您的活动发表了评论 我不能将多个通知写入单个记录,因为最终我将有与每个通知相关联的操作。 此外,在视图中,我希望当单个主题存在一定数量的通知时,通知将呈现为可扩展列表。 FooBar评论了你的状态(行动) Red1,Green2和Pink5对你的照片发表了评论[+] MegaMan和另外3人对您的活动发表了评论[ – ] MegaMan评论了你的活动(行动) ProtoMan评论了您的活动(行动) 巴斯评论了你的活动(行动) DrWilly评论了您的活动(行动) 干杯! PS我正在使用postgres和rails BTW。

Rails用户:您使用什么exception通知软件?

我见过Ryan Bates谈论exception_logger和exception通知。 还有其他好的东西需要考虑吗? 你喜欢和不喜欢这些什么? 另外,如果你抓住它们,这些exception通知程序会记录exception吗? 谢谢!

在Rails中实现通知

在我的应用程序中,我想在评论或post中提及他/她时通知用户。 用户句柄是@user_name ,类似于Facebook 。 提及的数据库表如下所示: Mention mentioned_by: user_id (foreign key) user_mentioned: user_id (foreign key) comment_id: (foreign key) post_id: (foreign key) 我无法想出实现它的方法。 Facebook / Twitter如何做到这一点? 我决定使用的是使用ActiveRecord callbacks/ Observer design pattern ,每当新的评论/post保存到数据库时,我都可以浏览post/评论的内容,并留意任何提及,然后执行通知按要求。 我觉得有一些缺失的部分,我没有把它弄好。 这是最好的方式吗?

Rails中的用户会话认证5

我正在尝试使用Rails 5中的操作电缆实现通知。 阅读Action电缆教程后,该电缆在会话和基于Cookie的身份validation上工作,以接收当前登录用户的通知。 module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified_user logger.add_tags 'ActionCable', current_user.username end protected def find_verified_user if verified_user = env['warden'].session(:user) verified_user else reject_unauthorized_connection end end end 在find_verified_user中,我无法从会话中获取用户对象。 任何人都可以帮助我,在行动电缆中validation用户。