Project

chatty

0.0
No commit activity in last 3 years
No release in over 3 years
Making it easy to set it up a live chat on your website.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

Code Climate Test Coverage Build Status

Chatty

Install

First bundle it in your Gemfile:

gem "chatty"

Execute bundle install.

Throw something like this in your application.js.coffee:

#= require chatty

Trow this in your ApplicationHelper:

class ApplicationHelper
  include Chatty::ChatsHelper
end

Add abilities for who can create and access chats through CanCan:

class Ability
  include CanCan::Ability
  
  def initialize(user)
    if user
      can :show, Chatty::Chat
      
      can [:new, :create], Chatty::Message
      can [:edit, :update], Chatty::Message do |message|
        if message.user == user
          true
        else
          false
        end
      end
      
      if user.email == "admin@example.com"
        can :manage, Chatty::Chat
        can :manage, Chatty::Message
      end
    end
  end
end

Usage

Create a chat somewhere in your code:

chat = Chatty::Chat.new(:user => current_user)

Show that same chat in a view:

<%= chatty_chat(@chat) %>

Try to view that chat with the user that got attached and with an admin in another window. Now start chatting!

Inspect the HTML to style that shit yourself!