Thanks for the link.

Its good to see this being added to rails.  My only nitpick is that I think you can do this in ActiveView, and not have to add extra code to the controller.  As Jamis points out, the controller is doing the same thing whether its serving html, xhtml or xml.  What's different is the template that gets rendered. 

It looks like Rails 1.1 provides this information via a new construct respond_to | wants, like this:

respond_to do |wants|
      wants.html
      wants.xml { render :xml => @people.to_xml }
    end

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.

Anyway - for a working plugin that implements this approach see:

http://cfis.savagexi.com/articles/2006/03/23/content-negotiation-and-rails

Thanks,

Charlie


Dr. Ernie Prabhakar wrote:
To be sure, this uses "content-type xml" to switch from web app to web service, but it is still pretty interesting.

- Ernie P.

http://jamis.jamisbuck.org/articles/2006/03/27/web-services-rails-style

The new REST web-service support in Rails 1.1 makes it so easy to add web-services to your app, you might as well do it earlier, rather than later.



_______________________________________________ microformats-rest mailing list [email protected] http://microformats.org/mailman/listinfo/microformats-rest


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
microformats-rest mailing list
[email protected]
http://microformats.org/mailman/listinfo/microformats-rest

Reply via email to