Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

acts_as_messenger

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acts_as_messenger

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= acts_as_messenger

Standard facebook-style messaging system. Not bound to any friendship structure. Integrates directly into your User model. Allows for users to comment on a thread, leave a thread, and be updated when a thread is commented on.

== Installation

Install the gem

gem install acts_as_messenger

Generate the necessary classes and migrations

script/generate acts_as_messenger

Migrate the DB

rake db:migrate

Add acts_as_messenger to your user model

class User < ActiveRecord::Base ... acts_as_messenger ... end

== Usage

With acts_as_messenger now incorporated into your User model, you have access to helper methods for creating messages and recipients. It's as simple as calling the send_message(title, body, recipients) method:

mike = User.find 4 john = User.find 3 sky = User.find 2

thread = mike.send_message('Message Title', 'Message Body', [john, sky])

OR

thread = mike.send_message('Message Title', 'Message Body', [3, 2])

The recipients of the message can be an array of AR objects or can be Fixnum's (or any combination). In the case of a Fixnum, the class type is assumed to be the same as the sending class.

From the thread object you can access the participants of the message directly. Participants are considered as the author of the message and anyone who's commented on the thread.

thread.participants => [mike]

john.comment_on(thread, 'Some comment')

thread.participants => [mike, john]

=== Privacy

All threads have a private_thread field. This allows the can_be_viewed_by? method to be utilized. The can_be_viewed_by? method checks to see if the object is either the author or one of the recipient objects:

random_user = User.find 490 thread.can_be_viewed_by?(random_user) => false

thread.can_be_viewed_by?(john) => true

== Copyright

Copyright (c) 2010 Mike Nelson. See LICENSE for details.

FAQs

Package last updated on 03 Feb 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc