Well, we’ve explored the basics of Rails and are advancing along in our applications, what else is there for Rails. There are more advanced features of Rails including callbacks, observers and rich associations (ie. join models). In addtion, there’s more to controllers such as a more RESTful interface for Rails 1.1. There’s a lot more to RJS templating and other non-ERB templates (such as Liquid). Let’s not forget making your own plugins, rake tasks, benchmarks and finally deploying your finished applications.
Advancing with Rails
- Advanced Active Record
- Rich Associations (has_many :through)
- REST (wants? xml/html)
- RJS templates
- Plugin Authoring
- View Templates
- Rake Automation & Script Runner
- Platform Integration (standalone apps and web services)
- Benchmarks and Profiling
- Deployment (Capistrano, lighttpd vs apache vs mongrel)
Now that you have your applications going, how can you share them with the world? They can’t stay running in Webrick on your local machine forever. The answer to this is not very cut and dry. There’s a multitude of platforms and environments that you can run your application in, but here’s some tips:
- Test throughly before deploying your application
- Try Capistrano (it will automate the process of deployment
- Run in production mode (development mode was only meant for the dev stage; it leaks memory and is not meant for normal traffic)
- FastCGI/SCGI over CGI (CGI will work on most machines, but slowly so if your platform supports FastCGI use it)
- Lighttpd and Mongrel are light and fast and can be tuned easily for Rails
- Some web hosting companies understand Rails better than others (TextDrive and Planet Argon lead the pack and contribute to the Rails community as well)
- Be a good citizen (some things in Rails are easy, but some require intervention. For example, Rails won’t clean up session files for you)
Django was developed around the same time as Rails and tauts many of the same leaps in productivity. It was built and extracted from the publishing world and from that has a handy admin interface that you get for free (much like scaffolded code in Rails). There seems to be some big changes afoot at the moment and Django should be better for it but there are no promises about backwards compatiblity until it hits 1.0. I walked through some of their tutorial and wasn’t happy with the a lot of the syntax. I’ve become fond of Ruby’s terse and concise syntax and some of the equivalent python code was pretty ugly. Some of that will or has changed with the upcoming release of 0.95, but I was working from the latest stable version 0.91.
From my brief flirtation with Turbogears, my first impressions were that it was much easier to pick up than the 0.91 version of Django (some of this seems to be fixed in 0.95 though). The syntax came out much cleaner and the pieces of the MVC puzzle fit more nicely with my Rails experiences. It fits python quite nicely in my opinion and I’d be interested in testing out it’s party line of being the “rapid web development megaframework you’ve been looking for.”
This framework is much younger than Django and is built on existing technologies. I’m not sure it’s been throughly tested on high-traffic sites.
PHP on Trax, Biscuit and Cake are PHP Rails clones, and like many Rails clones they mimic Rails but can’t really reproduce the Ruby experience. Both projects may help spread the desirable practices learned from the experience of developing with Rails (such as unit testing, code separation and DRY practices), which is great even if less satisfying than the original.
PHP Framework Bits
Smarty is often used for templating in the PHP world. It allows you to separate out your logic code from your page views. DB_DataObject is the boring name for the PEAR project to implement ActiveRecord like functionality with a PHP approach.