RESTful_Easy_Messages
- 16th October , 2007 by Sam in Ruby on Rails
- 32 comments | Add my comment
So three month ago I released my first Rails plug-in, Easy_Messages (EZM), and I was pleasantly surprised by the response, excited that people were actually using my code. Then I became paranoid as people were actually using my code! Since then I worked briefly on a project which was written with REST in mind and was forced to look into it. Up to that point I had been doing my best to not meet REST in the hallway as I was a little scared by him. I don’t know why? After watching the Peepcode screencast by Geoffrey Grosenbach, everything clicked and I realized that I could make the code for EZM much better. The end result is this plug-in. I hope you find it useful.
The code is hosted at GitHub.
Here’s how to install the plug-in. (Rails 2.1 required for git plug-ins)
./script/plugin install git://github.com/sschroed/restful_ezm.git
Here’s how to run the generator.
For standard html views: ./script/generate messages erb
For haml[1] views: ./script/generate messages haml
[1] You will need to install the haml plug-in for the views to render properly.
I’ve tried to decouple as much of the code as I could with this release. If you used Easy_Messages you’ll remember most of the code was stuck in the plug-in directory. With REZM the generator will put a controller, helper, model, tests, and a few other support files right into your project for easy access. To see the entire list view the FILELIST in plugins/restful_easy_messages. There is still a tiny bit of code in the plug-in though.
If you are using Rick Olson’s RESTful_Authentication you can get REZM up and running with minimal setup as I pulled it from a project that uses it.
First, update the user model.
Then add the REZM routes.
NOTE: Routes have been changed in the lastest release on GitHub. The User is no longer needed. This break backwards compatibility, unfortunately. Thanks to Gravis for the update.
Now run db:migrate and you should be good to go.
But what if you didn’t use restful_authentication? Having to use Acts_As_Authenticated for EZM was the biggest complaint that I heard so I made REZM with hooks for you to switch out R_A if you want. Open lib\restful_easy_messages_controller_system.rb to do so. Just replace the current_user and login_required methods with calls to similar ones in your application.
I believe that is it. Oh wait, there is also an Atom feed for the inbox!
If you wish to try out REZM I’ve set up a sample app. You can message the user “sam” if you want to test writing a mesasge.
***** Click to play with the REZM Sample App. *****
Thanks to…
**Geoffrey Grosenbach for the REST PeepCode
**Matt Beedle for writing and releasing Acts_As_Emailable which was my starting point with Easy_Message and now RESTful_easy_messages.
** Rick Olson for writing and releasing all of his plug-ins.
** Dr. Nic Williams for his multiple-openids-per-user-sample-app which I used as a starting point for the REZM sample app which I’ll put up soon.
** Ben Curtis for his OpenID sample app which Dr. Nic based his.
Lastly, please recommend me if you like RESTful_Easy_Messages.


