internal mail system

50 views
Skip to first unread message

Darren Evans

unread,
Mar 12, 2007, 12:34:35 AM3/12/07
to rubyonra...@googlegroups.com
Hi

I would like to develop a small internal messging system (using user
ids) for a web site I have developed so that users can communicate with
each other using a messaging system. I envisage main menus of: new,
sent, inbox with all of the usual features in these sections included
(eg. delete, delete all, reply, forward). Users should be able to send
messages to users that they have predefined on a list.

Before I undertake quite a lot of development, I wondered whether anyone
had done this already and would be prepared to share the code or if
anything is commercially available to integrate into my application?

I don't really want to start re-inventing the wheel if there is an easy
solution.

Any advice on how best to proceed would be really appreciated.

Many thanks

Darren

--
Posted via http://www.ruby-forum.com/.

Phlip

unread,
Mar 12, 2007, 6:31:05 PM3/12/07
to rubyonra...@googlegroups.com
Darren Evans wrote:

> I don't really want to start re-inventing the wheel if there is an easy
> solution.

A blog, right? Just install Mephisto or one of the others. Blogs with
message boards are where it's at. Even simpler, a Wiki. The Recent
Changes is the daily inbox.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!

Darren Evans

unread,
Mar 13, 2007, 1:16:01 AM3/13/07
to rubyonra...@googlegroups.com
Hi Phlip

Thanks very much for your reply, I really appreciate it. Mephisto looks
really interesting, but it's not exactly what I am looking for this
time.

I would like a system where one user sends a message to another user,
rather than one user sends a message to all users. Something like an
internal email system within the application is the best way that I can
describe it, but using user ids rather than e-mail addresses

Maybe I could adapt Mephisto by adding some conditions, or is there
something more appropriate?

Thanks

Darren

--
Posted via http://www.ruby-forum.com/.

Chris T

unread,
Mar 14, 2007, 2:48:23 PM3/14/07
to rubyonra...@googlegroups.com
Yup, I've implemented one. Really easy to roll your own, particularly if
you're using REST. My model is really simple, with just a few
validations and utility methods:

class Message < ActiveRecord::Base
validates_presence_of :title, :body, :recipient_id, :sender_id
belongs_to :sender, :class_name => "User", :foreign_key => "sender_id"
belongs_to :recipient, :class_name => "User", :foreign_key =>
"recipient_id"
attr_accessible :title, :body, :recipient_id

# aliases read_at accessor attribute to make it read more nicely
def read?
read_at
end

# returns the opposite_party in the messsage to given user. So if the
given user is the recipient,
# this method returns the sender and vice versa. If the given user is
neither a recipient nor sender
# (e.g. because they're an editor) it returns the recipient. If the
given user is nil (e.g. because
# the current_user is nil) an exception is raised
def partner_to(user)
raise ArgumentError unless user
user.id == recipient_id ? sender : recipient
end
end

In User model (which is based on acts_as_authenticated), I've got the
following associations:

has_many :sent_messages, :class_name => "Message", :foreign_key =>
"sender_id", :order => 'created_at DESC'
has_many :received_messages, :class_name => "Message", :foreign_key =>
"recipient_id", :conditions => ['deleted_at IS NULL'], :order =>
'created_at DESC'
has_many :unread_messages, :class_name => "Message", :foreign_key =>
"recipient_id", :conditions => ['read_at IS NULL AND deleted_at IS
NULL'], :order => 'created_at DESC'

The schema for the Message class is:
create_table "messages", :force => true do |t|
t.column "title", :string
t.column "body", :text
t.column "recipient_id", :integer
t.column "sender_id", :integer
t.column "created_at", :datetime
t.column "deleted_at", :datetime
t.column "read_at", :datetime
end

Hopefully should be enough to get you started.

Darren Evans

unread,
Mar 15, 2007, 3:13:28 AM3/15/07
to rubyonra...@googlegroups.com
Chris,

Thank you very much for this. It looks like an excellent start for me to
build on.

Darren

Priya Saini

unread,
Sep 14, 2007, 6:59:25 AM9/14/07
to rubyonra...@googlegroups.com
Darren Evans wrote:
> Chris,
>
> Thank you very much for this. It looks like an excellent start for me to
> build on.
>
> Darren

Hi All:

I am also looking for the same internal messaging application. N
wondering if any such functionality is already available with ROR.

Any help will be highly appreciated.

Thanks and Regards,
Priya Saini

vanquisher

unread,
Sep 17, 2007, 9:11:15 AM9/17/07
to Ruby on Rails: Talk
I found this
http://matt-beedle.com/2007/06/05/acts_as_emailable/

But can someone tell me whether this is ok to use? or has someone used
it?

also...how do i take mephisto's emailing feature????
pls let me know.


On Sep 14, 3:59 pm, Priya Saini <rails-mailing-l...@andreas-s.net>
wrote:


> Darren Evans wrote:
> > Chris,
>
> > Thank you very much for this. It looks like an excellent start for me to
> > build on.
>
> > Darren
>
> Hi All:
>

> I am also looking for the sameinternalmessaging application. N

Matt Beedle

unread,
Oct 8, 2007, 3:02:39 PM10/8/07
to rubyonra...@googlegroups.com
Hi,

I have been using my acts_as_emailable plugin on a number of sites which
I am currently developing and it has working fine for me so far. It
only gives you the models and associations though, you will need to
write the views and controllers yourself. This is very simple to do
though. I have written some examples on my blog here
http://matt-beedle.com/2007/06/05/acts_as_emailable/.

One thing this plugin does not allow you to do however, is to send a
message to multiple users, like a myspace bulletin. Well, it could be
done, but with lots of data duplication. Please get in contact if you
need any help with this and I'll be more than happy to lend a hand.

Regards,

Matt

Reply all
Reply to author
Forward
0 new messages