Recent Blog Posts
Blogs » Ruby on Rails
Get on Track
: Ruby on Rails BlogThis week in Rails - 09/06 to 13/06
It seems that testing has been on the flavour of the week, which is apt really as I myself have been playing with RSpec a lot lately (Blog post forthcoming, once I finish up one of the projects that has been using said testing framework).
Simon Harris from My hovercraft is full of eels describes a simple way to break up you tests into DRY, manageable chunks: http://www.redhillconsulting.com.au/blogs/simon/archives/000429.html
Ben Mabey shows you how to use Macros in RSpec, using Shouda. Macros are as old as the hills, but can be really handy to organise many tasks simply: http://www.benmabey.com/2008/06/08/writing-macros-in-rspec/
Michael Ivey reminds us why we should use tests. Not only are they a nice support net, but they encourage us to write better code. It’s like extreme programming without the other programmer: http://gweezlebur.com/2008/6/13/tests-make-you-write-better-code
Outside of the testing arena, a new version of Capistrano — possibly the coolest tool for Ruby — has been released. If you haven’t had a play with Capistrano yet, go and install it and try it out.
And finally for this week, if you have ever been perplexed about whether pieces of code belong in the Model, View or Controller, Starjuice has an article that may give you a clue or two, …
This week in Rails - new release edition
Rails 2.1 release
This week saw the release of of version 2.1 for Ruby on Rails. You can see the announcement on the official Rails blog.The new major features are:
- Time zones (by Geoff Buesing)
- Dirty tracking
- Gem Dependencies:
- Named scope (by Nick Kallen)
- UTC-based migrations
- Better caching
IronRuby runs Rails
The IronRuby team also announced this week that they managed to get a “Hello World” example running on an unmodified Rails stack. Although it’s not yet ready for prime time, we are one step closer to being able to run Rails on .NET. See the announcement on Jon Lam’s blog.
RailsConf
RailsConf was held in Portand this week. Unfortunately a trip to the US was stretching the budget a little, so if you were like me and unable to make it, check out Gregg Pollack’s video compilation of a number of interviews he had with some of the speakers. RailsConf in 36 Minutes.
Until next time Railers!
Did Rails Sink Twitter?
Twitter is arguably the most heavily used Ruby on Rails application in the world. Almost since its inception, Twitter has fostered a wildly passionate cult following. Also from the beginning, Twitter has suffered from chronic outages under that load.
In the past month, record downtime has prompted fresh outcry within its ever-growing user base. This, along with increased attention from mainstream media has forced Twitter to publicly acknowledge these issues, and to reveal a few details about the source of these problems.
Though there has been much speculation about the source of Twitter’s performance issues, the closest we have had to a real peek under the hood has been this Twitter Developer Blog post:
Twitter is, fundamentally, a messaging system. Twitter was not architected as a messaging system, however. For expediency’s sake, Twitter was built with technologies and practices that are more appropriate to a content management system.
But wait, what exactly do they mean by “technologies and practices”? Could they mean Ruby on Rails?
Twitter and the Curse of the Framework
Ruby on Rails is a Model-View-Controller (MVC) framework. To build an application in Rails, you start by defining a collection of objects that model the things your application will do, then you write controllers …
Simply Rails 2: Your Rails 2 beginners book
The first edition was touted as the ultimate rails beginners book and read by 10’s of thousands of people. I’m pleased to announce a 2nd edition to Patrick Lenz’s brilliant book…
It’s called Simply Rails 2 and is available for purchase right now in PDF or Printed format at sitepoint.com.
Grab the printed version for just $39.95 or the PDF version for just $29.95.
With Simply Rails 2 you’ll learn how to build bulletproof Web applications from scratch, with more features using less code.
Patrick’s updated the entire book to take advantage of all the new Rails 2 features. It’s the only beginner’s book we know that’s Rails 2 ready…
Inside the book you’ll learn how to:
- Build and deploy your own Rails web application.
- Reap the benefits of using best-practice MVC architecture.
- Use Rails’s Ajax features to create slick interfaces.
- Interact with databases easily using ActiveRecord.
- Add the magic of REST to your apps with Rails Resources.
- Use plugins to enhance your applications easily.
Simply Rails 2 will show you that there is a simple and easy way to build web 2.0 applications.
Grab yourself a copy today!
Rubinius runs Rails
There was a short note today, that the Rubinius development team has successfully run Rails on their virtual machine. Although isn’t anywhere new production ready yet, it is a significant step forward in getting a faster Rails.
I covered some of the alternate Ruby implementations previously.
Congratulations to the team!
Rails 2.1 release candidate 1 is on its way
Word out on the wire is that Rails 2.1 RC1 has been tagged in the repository, so the gems should be available shortly. Being a point release, the changes aren’t major - mainly bug fixes and some performance improvements, but there are still some new features that will make it worth a look.
Updated timezone support
Timezones will finally become a first class citizen in Rails. You will be able to set the timezone, and all subsequent time calls will be with in that zone.
Time.zone = “Australia/Perth”
Time.zone.now # will return something like Wed, 24 May 2008 22:56:00 WST +08:00
Better Gem dependencies
If you rely on gems in any of your projects (and why wouldn’t you? Code re-use and all that), you may have come across the pain of gem versioning. Rails 2.1 will allow you to stipulate what versions of each gem you need.
config.gem “chronic”, :version => ‘0.2.3′
It also adds a rake task that will automatically install the right gems for you.
rake gems:unpack
Improved caching
Previously, the only caching options Rails developers had was based around file fragments, which is fine for single server setups - but scaling that up to multiple servers could cause synchronisation issues, causing your cache to go stale. …
Smooth your deployment with Passenger
I alluded to the release of Phusion’s Passenger (AKA mod_rails) - an Apache module that can run multiple Rails sites, just as PHP does. The significance of this is pretty huge. Up until now, running rails has required running Mongrel behind an Apache proxy or using FastCGI (or preferably fcgid).
Although Mongrel did a sterling job, I have never been a big fan of having two points of failure - problems with either Apache or Mongrel would render your site unreachable. Not only that, adding capacity to your system required adding a number of mongrel instances, each with it’s own port and each with it’s own memory overhead, which can get very messy for shared hosting providers.
Passenger will allow hosting providers to install one Apache module, requiring the client to simply upload their application - no permission issues, or troublesome configurations files. However, it is also very useful for a developer - instead of having to run script/server when testing your application, you can install a local version of Apache, setup a few virtual hosts, and have instant access to your test sites.
Currently, Passenger only runs on *NIX type environments, eg Linux and OSX. The Phusion team have worked pretty …
Ruby On Rails Linkage: GitHub, Passenger and more…
The Rails core team is inching towards version 2.1 of Rails which adds a myriad of new features including named scopes, gem dependencies and native timezone support. The official launch of GitHub has seen an explosion of articles on how to use Git, and it looks like Rails can finally become a first class citizen on shared hosts. Here are some links where you can find out more:
- Geoff Buesing goes through the new Timezone support
- Ryan Daigle explains the new named_scope functionality and how Gem dependencies work
- Peter Cooper runs through some more resources for working with Git
- Phusion releases Passenger (AKA mod_rails), that allows Rails applications to be deployed via an Apache module, in a similar manner to PHP.
More on Passenger later.
Subversion gits the last train
There has just been an announcement that the Rails-core source code version control repository is moving over from Subversion (SVN) to git and they will be using Lighthouse for bug tracking instead of trac. Does this affect you? Not directly (unless you like playing on edge-rails), but it is a good excuse to talk about source code repositories and some of the differences between subversion and git.
What’s source-code version control?
Source-code repositories provide you with a central place to store your code — they will generally do this whilst maintaining a history of your “commits” (The action of saving code back to a repository). This means that you are able to roll back code any change that you have made. If you have ever been over-zealous with the rm -rf command, you may understand why this might be handy.
Another cool feature is the ability to branch (or take a copy of) your code - this allows you to keep, say, a development and a stable version. If you find a bug that needs patching in your production version, you can merge the change back in to the development branch thus avoiding regressions bugs.
There are a number of version control systems out …
Other cool ruby projects
With all the noise that Rails makes, you would be forgiven for thinking that it is the be all and end all of the Ruby world - sure it has popularised the language, but there are lots of other cool projects using the Ruby. Here are a few:
Merb
Merb is another full-stack web framwork, which works a lot like Rails. However, the author has stripped quite a bit of the fat away, and made the framework mush less opinionated as well as making it thread-safe. Rather than having a large monolithic core, Merb tries to be as modular as possible relying on third party gems for much of it’s functionality.
It includes support for different Object-Relational mappers (ORMs - the thing that mediates transactions between your application and your database), including DataMapper, Sequel and even the Rails default ORM: ActiveRecord.
Merb stands for Mongrel + ERB, so it isn’t suprising that they make up a significant part of the framework, although you can use HAML and SASS as your templating engine.
Camping
Camping is a micro-framework (only 4k!) designed by the disturbingly talented Why the Lucky Stiff. It is probably more an exercise is seeing how much you can do with little code, but …
Sponsored Links
SitePoint Marketplace
Buy and sell Websites, templates, domain names, hosting, graphics and more.
Logo Design, Web page Design and more!
- Custom logo designs created ‘just for you’.
- Pick the design you like best.
- Only pay if you’re satisfied with the result.
SitePoint Kits
Download sample chapters of any of our popular kits.
The Web Site Revenue Maximizer
The Search Engine Marketing Kit, 2.0
The Web Design Business Kit 2.0
The Email Marketing Kit
The Usability Kit
SitePoint Books
Download sample chapters of any of our popular books.
Simply Rails 2
The Principles Of Project Management
The Ultimate CSS Reference
The Art & Science of JavaScript
The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition
The ASP.NET 2.0 Anthology: 101 Essential Tips, Tricks & Hacks
The CSS Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition
Simply JavaScript
The Art & Science Of CSS
The Principles of Beautiful Web Design