Ruby-on-Rails

Walkthrough of Rails’ new REST support

HTTP Request => Rails 'params'

GET: /users => [:action => 'index']
GET: /users.xml => [:action => 'index', :format => 'xml']
GET: /users/1 => [:action => 'show', :id => 1]
GET: /users/1;edit => [:action => 'edit', :id => 1]
GET: /users/1.xml => [:action => 'show', :id => 1, :format => 'xml']
POST: /users => [:action => 'create']
PUT: /users/1 => [:action => 'update', :id => 1]
DELETE: /users/1 => [:action => 'destroy', :id => 1]

Prolific 'Edge Rails' blogger Ryan Daigle has written "Simply RESTful Support - And How to Use It", a great walkthrough of the features offered by the simply_restful plugin that's now a core part of Edge Rails and which will provide a lot of the new functionality to be seen in Rails 1.2.

Read more →

Refactoring a Rails app to be RESTful

Scott Raymond has written a useful article showing the thinking behind his refactoring of IconBuffet.com from an action-heavy URL scheme to a REST based URL scheme.
The application behind IconBuffet.com, a royalty-free stock icon store, went from 10 controllers and 76 actions to 13 controllers that more closely followed the models involved, and 58 total actions. Most of the new actions are uniform and match to the new Rails methodology of mapping HTTP verbs (GET, PUT, POST, DELETE, etc.) to Rails controller actions. You can learn more about this structure from David Heinemeier Hansson's slides (PDF) from RailsConf, or watch the video of his keynote presentation.

Read more →

Pre-processing / normalizing parameters in Rails

Bruce Williams tries to solve the problem of multiple parameter types in Rails. For example, an action may accept dates via a parameter, but dates may be supplied in many forms. A 'date' parameter might arrived as if from a date_select helper, or might even be typed in directly by a user, or be pulled from a database. Rather than use before_filters to check parameters and normalize them, Bruce suggests that it should be possible to add basic conversion tools to certain data types so that all data is normalized by the time it hits your controllers.

Read more →

Providing context for Rails’ controller action

There are many scenarios where you might want the same controller action / method in your Rails application to perform multiple functions. For example, a wizard with multiple steps or a single form with multiple-stage AJAX calls. What you want to do is provide a 'context' to the specific request and have the controller handle that in some different way.

Read more →

RaPT: A Better Plugin Manager for Rails

Geoffrey Grosenbach introduces the RaPT Plugin Manager for Rails, the answer to the problem of slow plugin installation. Installable as a gem (gem install rapt), RaPT caches the locations of different plugins so that installation is quick and easy. Future plans include developing a central plugin repository, auto-announcement of self-developed plugins, and automatic plugin upgrading. If you want the files direct, check out the Rubyforge project site for RaPT.

Read more →

Testing for Rails Helpers

You can test your controllers, your models, and, well, most of your application, but till now there hasn't been a way to explicitly test your Rails application's helpers. Now there's a solution.. the helper_test plugin (with source and instructions).

Read more →

MeantimeFilter: Wrap your Rails controller actions with scopes

MeantimeFilter is an interesting new plugin for Rails by Roman Le Negrate. It's a little like around_filter, but rather than using a class with 'before' and 'after' methods, it uses a single method (like the other types of filter) and passes in the method to wrap 'around' as a code block. You can then yield to this or pass it into anything you like. An example:

Read more →

Using Oracle databases with Ruby

I don't know much about Oracle, but many people have asked about Ruby's support for Oracle. One of my clients is also attempting a project with Rails and Oracle. Here are some useful resources I've found:

Read more →

Streamlined: Even faster Rails application development

Streamlined is a framework that sits about Ruby on Rails and makes developing Rails applications even quicker than possible with scaffolding alone. It includes a ton of useful stuff like pre-built layouts, a REST layer around all the models, support for Atom, and its own DSL. As developer Justin Gehtland explains:

Read more →

Slingshot: Ruby on Rails Business Hosting

Slingshot
Slingshot is just one of many hosting companies getting on the Rails bandwagon. Unlike many, though, Slingshot was launched specifically with Rails in mind, as the tagline says: "When we couldn't find a reliable Rails host, we created our own." If you use the service and have any comments or a review, do post in comments here.

Read more →

Railsbench: Measure the raw speed of Rails applications

Railsbench, by Stefan Kaes, is a collection of scripts that makes benchmarking a Rails application quick and easy. Rather than benchmark over HTTP, Railsbench tests the 'raw' speed of your application directly, and won't include latencies involved with the network or between your HTTP daemon and Rails. If you love statistics, you'll love Railsbench. Here's some demonstration output:

Read more →