Skip to content

whmall/the_notify

 
 

Repository files navigation

TheNotify

Short description and motivation.

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 'the_notify/cable', 'data-turbolinks-eval': 'false' %>
<%= stylesheet_link_tag 'the_notify/cable' %>

View: add link

<%= link_to notifications_path, class: 'item', remote: true, id: 'notify_show' do %>
  <i class="bell icon"></i>
  <span id="notice_count" style="padding-left: 5px"><%= current_user.unread_count %></span>
<% end %>

Model Setting

# which model can receive notifications
class User < ApplicationRecord
  include TheReceivable
end

Controller Setting

class ApplicationController < ActionController::Base
  include TheNotifyController
  
end

Channel Setting

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

  end
end

Installation

Add this line to your application's Gemfile:

gem 'the_notify'

And then execute:

$ bundle

Or install it yourself as:

$ gem install the_notify

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

Packages

No packages published

Languages

  • Ruby 36.4%
  • JavaScript 22.8%
  • CSS 22.2%
  • HTML 18.6%