You are here: Browse Railsplugins Acts As Emailable
acts_as_emailable is a plugin developed to solve a problem I seem to come up against quite regularly when developing sites with a certain level of user interaction. The aim is to make it as easy as possible for anyone to create an internal email system within their site.
First up you need to install the plugin. This can be done like so:
script/plugin install svn://matt-beedle.com:3396/acts_as_emailable
Then generate the model and migration for the emails table.
script/generate acts_as_emailable_model Email
rake db:migrate
Now you are ready to go. Just add the following line of code to your User model:
class User < ActiveRecord::Base
acts_as_emailable
#
# The rest of you code
end
After the plugin is installed the following methods become available to your User class.
These methods are the associations. They return what you would expect: user.users_whom_i_have_emailed user.users_who_have_emailed_me user.unread_mail user.read_mail
Return all users who have emailed or been emailed by the user along with the associated email data user.all_mail
Return all new mail (alias for unread_mail) user.new_mail
Return all old mail (alias for read_mail) user.old_mail
Accepts a user object as the receiver, and an email and creates an email relationship joining the two users user.send_mail(receiver, email)
Copyright© 2007 Matt Beedle, released under the MIT license
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly