A few weeks ago I was looking for Rails plug-in to provide simple messaging between users on a website. I came across Acts_As_Emailable by Matt Beedle. It was a good start but only gave me a model and some methods but I would still need to flesh out a controller and some views for my little private messaging project to be complete. The result of that work is this plug-in, Easy_Messages. I took Acts_As_Emailable as a starting point and added some controller methods, a few views, a helper, and some named routes.
Below are the installation instructions. This is my first Rails plug-in so let me know if you find something to refactor. I’m open to constructive criticism.
The code is hosted at RubyForge.
UPDATE I: I have created a new branch for 0.51, please use that one for the latest stable release
UPDATE II: I have removed the docs from branch 0.51 and placed them online here: http://easymessages.samuelschroeder.com. Now the generator should work like a charm
svn://rubyforge.org/var/svn/easymessages/branches/RB-0.51
The run the generator to create the model, migration, helper, and views.
script/generate easy_messages message account
Note: Easy_Messages assumes you have Acts_As_Authenticated installed with the defaults of a model named User and a controller named Account. And you must use the above line exactly. I have grand aspirations of making the generator fully dynamic someday but for now you’ll have to deal.
The generator should produce this output.
exists app/models/
exists app/helpers/
exists app/views/account
create app/models/message.rb
create app/helpers/easy_messages_helper.rb
create app/views/account/message_view.rhtml
create app/views/account/messages.rhtml
create app/views/account/send_message.rhtml
exists db/migrate
create db/migrate/###_create_easy_messages_messages.rb
Yes, I realize the redundant naming but once/if I get the dynamic generator going it would say ###_create_easy_messages_[MessageClassNames]s.
Now you have to do three manual changes to your code. First, add “easy_messages” to apps/model/user.rb.
Second, add “authenticated_commands” to apps/controllers/account_controller.rb.
Finally, you need to copy the named routes from vendor/plugins/easy_messages/config/easy_messages_named_routes.rb to config/routes.rb.
That should be it for the setup. So start your development server and point your brower to..
http://localhost:3000/account/inbox
There is also a complete RDoc listing in vendor/plugins/easy_messages/doc
Thanks to…
**Matt Beedle for writing and releasing Acts_As_Emailable.
** Rick Olson for writing and releasing the kick-ass Acts_As_Authenticated plug-in. It was been such a help when starting new projects.
