David committed the simply_restful plugin to the rails this afternoon, ensuring its inclusion with the next release of Rails. Beware, there are a few API changes from the plugin, and a nice new feature:
# OLD map.resource :post map.resource :comment, :path_prefix => '/posts/:post_id' map.resource :trackback, :path_prefix => '/posts/:post_id' # NEW map.resources :posts do |posts| posts.resources :comments, :trackbacks end
Nesting the resource blocks will automatically set the path prefix from the parent’s path.
There may be some bugs introduced in the move from plugin to core, so try upgrading (and remember to remove the plugin!) and let us know if you find anything. I have the current version running on a couple apps now, so things should be working.
Update: There is one more restriction I forgot to mention. The _method hack only works on POST methods now. It is no longer valid to link to a URL like /articles/1?method=delete. Let’s not open that can of wormsvengeance.php again.
Tip #1: Use my routing navigator plugin to get a handle on what routes are being created.
Tip #2: Use the new *_path routes if you want your routes to have just the path (‘/articles/1’) instead of the whole url with protocal and host.
As Mongrel continues to bubble to the top of the preferred production stack, we’ve started to evaluate web servers on their proxy rather than their FCGI support. The lighttpd crew has heard this change of priorities loud and clear and the coming version will feature a brand new mod_proxy_core module, which aims to rectify all the troubles of the old mod_proxy.
All hail the http pipe!
If you have trouble wrapping your head around assert_tag and its options, you might want to give CSS selectors a chance instead. There are currently two plugins for handling that: assert_select and hpricot helper.
The hpricot style gives you something like
assert element('title').should_contain('Funky Chicken Title') and the assert_select gives you something like
assert_select "title", "Welcome".
From a brief cursory overview, I tend to like the assert_select style better. But I have yet to use either for real stuff. Please do shoot a comment with your experiences. One of these methods could well make it into core.
Dr Nic Williams has charged one of the major strongholds of legacy database compatibility with Rails, composite primary keys support. By installing his nimble plugin, you get a very natural API for mapping those blasted composites using
set_primary_keys and an array of keys.
It’s still a work in progress, but if you have to deal with a legacy database and want to use Rails, this might just be your ticket in.
I’m only a week behind on the release of Typo 4. Typo is one of the oldest and most visible of Rails open source projects, so it’s always nice to see a new release. Out of all the new features and bug fixes, what really stood out for me was the Typo installer. Scott has recently extracted this into its own gem, ready for inclusion with your own Rails applications!
Typo now includes a .gem-based installer that makes it easy to install Typo. Just install the Typo gem (gem install typo) and run the Typo installer (typo install /some/path) to create a new Typo blog in /some/path. The installer will install all of Typo’s files, create a working set of config files, create a SQLite database for you, and start the Mongrel web server on a random TCP port. It’ll also create a set of sample Apache and Lighttpd configuration files to show you how to tie Typo into your existing web server. — Typo Installer
It seemed to have slipped all of our minds, but yesterday, the 25th of July marks the 2 year anniversary of Rails’ release.
Here’s David’s announcement email to the ruby-talk mailing list.
Cheers to you early adopters.
Jay Zimmerman just wrote to say that next Wednesday, July 26th, the presentation media for RailsConf 2006 will go on sale to the general public. So if you didn’t get to the conference, you can pick up all the slides with synced audio for $100. Surf on over to the ScribeStudio site for more information. And remember, videos of the seven keynote presentations are being made available for free download too.
Gonzo Rails developer Scott Raymond has written an analysis of how he refactored IconBuffet.com using RESTful routes. It’s the most cogent and compelling description of the benefits of a CRUDdy/RESTful design that I’ve seen. He reduced the number of actions in the application by 25%, and reduced the size of his routes file from 16 lines to 3. Isn’t small beautiful?