/
README
39 lines (27 loc) · 937 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
= 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 (http://ruby-blog.pl), released under the MIT license