I am absolutely loving the RESTful support in Rails 1.2. It uses conventions to tilt the playing field toward domain-driven design. Yum, yum, yum. My favorite use of conventions in Rails yet. The URLs are meaningful, the controllers now have a clear design, it's an appropriate and extensible abstraction, life is good and Rails apps are much improved for it.
But I ran into a hitch that foiled me for a little while. I only solved it by spelunking into the code, so I'm posting the solution in hopes that Google will be a better friend about this.
Simply providing a :format
option to a resource's named route doesn't work as expected.
photo_path(:id => 1, :format => 'png') #=> /photo/1?format=png
Instead, the resources
routing method defines a separate named route prefixed with formatted_
:
formatted_photo_path(:id => 1, :format => 'png') #=> /photo/1.png
Tricky...I wonder what it would take to make this complication unnecessary.