Skip to content
Ruby
Pull request Compare This branch is 16 commits ahead of software-project:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
rails
test
.gitignore
MIT-LICENSE
README.rdoc
Rakefile
VERSION
acts-as-messageable.gemspec

README.rdoc

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

Something went wrong with that request. Please try again.