[uf-rest] Web services, Rails-style (in 1.1)

David Heinemeier Hansson david at loudthinking.com
Mon Mar 27 18:07:16 PST 2006


> But why not just have active record pick the correct template?  To  
> do this requires assigning template extensions to mime types.  For  
> example, html goes to  .rhtml, xml goes to .xml, xhtml goes  
> to .rxhtml, etc.  This would be easy enough to do - in fact Rails  
> is 99% of the way there already.  And it seems in line with Rails  
> being opinionated software.  Once you make that assumption,  
> ActiveView can do the rest of the work.  Of course, you should be  
> able to override that choice in the controller using the same  
> mechanism Rails current supports.

Lots of people use rxml to generate HTML. Or RSS. Or Atom. And this  
is helpful because it allows you to do things like:

respond_to do |wants|
   wants.html { redirect_to :action => "index" }
   wants.js
   wants.xml do
     headers["Location"] = url_for(:action => "show", :id => @person)
     render :xml => @person.to_xml
   end
end

In the face of this common requirement, I don't like to introduce a  
binding between mime type and template types.

(I do like the resource :person syntax from your other article,  
though ;))
--
David Heinemeier Hansson
http://www.37signals.com    -- Basecamp, Backpack, Writeboard, Tada
http://www.rubyonrails.com  -- Web-application framework
http://www.loudthinking.com -- Broadcasting Brain




More information about the microformats-rest mailing list