Private messaging in Rails.
What it do?
acts_as_messageable is a plugin for enabling private messaging between users. Conversations, multiple recipients, trash, sentbox... its all in there.
> script/plugin install http://actsasmessageable.googlecode.com/svn/tags/acts_as_messageable-1.0.1 > script/generate messageable > rake db:migrate
class User < ActiveRecord::Base acts_as_messageable end
phil = User.find(3123) todd = User.find(4141) phil.send_message(todd, "whats up for tonight?", "hey guy")
sends a mail to todd's inbox and puts the sent message in phil's sentbox.
returns an array of all unread mail messages in todd's inbox.
mail = todd.mailbox[:inbox].unread_mail todd.reply_to_sender(mail, "not sure, probably having a few dozen cocktails.")
replys to the sender of the mail message. (Messages can be sent to multiple users, and are conversation based. See the RDoc.)
moving / deleting:
convo = mail.conversation todd.mailbox.move_to(:trash, :conversation => convo)
moves all mail messages to the 'trash' that are part of the given conversation. There are 3 default mailboxes for each user (:inbox, :sentbox, :trash), although any name can be passed to this method if you wanted to implement folders.
returns the last message received for each conversation you are involved in. Pretty sweet for an inbox view.
Check the RDoc.