Skip to content

software-project/acts_as_messageable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActsAsMessageable

The Acts As Messageable allows communication between the models.

Usage

To use it, add it to your Gemfile:

gem 'acts-as-messageable'

Post instalation

  1. rails g acts_as_messageable:migration

  2. rake db:migrate

Usage

class User < ActiveRecord::Base
    acts_as_messageable
end

@user1 = User.first
@user2 = User.last

# user1 send message to user2
@user1.send_msg(@user2, "Message to user2", "Hi user 2!;-)")
@user2.send_msg(@user1, "Re: Message to user2", "Hi there!:)")

# Show inbox
@user1.recv
# Show outbox
@user1.sent

# Search message
@user1.msg # all messages (in and out)
@user1.msg(:from => @user2) # all messages from @user2
@user1.msg(:to => @user2) # all messages to @user2
@user1.msg(:id => 2) # message where message.id = 2

Copyright © 2010 Piotr Niełacny (ruby-blog.pl), released under the MIT license

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%