Skip to content

work-design/rails_notice

Repository files navigation

RailsNotice

测试 Docker构建 Gem

RailsNotice 用于处理通告(Annunciation),消息(Notification);

特性

  • 只在用户请求数据时快速生成通知记录,避免僵尸用户产生的死数据;

Usage

Set the cable.yml

Should set adapter as redis in development

development:
  adapter: redis
  url: redis://localhost:6379/1

Import the js and css in the page which you want show notifications

<%= javascript_include_tag 'rails_notice/notice_channel', 'data-turbolinks-eval': 'false' %>
<%= stylesheet_link_tag 'rails_notice/cable' %>

View: add link

<%= render 'notice_link' %>

Model Setting

# which model can receive notifications
class User < ApplicationRecord
  include Notice::Ext::Receiver
end

Controller Setting

class ApplicationController < ActionController::Base
  include RailsNotice::Application
  
end

Channel Setting

module ApplicationCable
  class Connection < ActionCable::Connection::Base
    prepend RailsNoticeConnection

  end
end

许可证

遵循 MIT 协议