Elsewhere

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 →

“The Ruby Conspiracy” : July’s Troll Of The Month

It's time to bring in a regular feature.. Troll Of The Month. Every month or so there appears to be a new article circulating that explains why 'Ruby sucks' or why you shouldn't use Rails to develop serious applications. Most of the time, they're unbalanced and poor explained, even if the author has some valid points.

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 →