Ruby response_to method February 02, 2007 06:08 over 5 years ago
Denne Ruby on Rails metode henter alle order på et produkt og retunere i XML, html eller javascript til brug for Ajax. cool
@product = Product.find 1234
@orders = product.orders response_to do |format| format.rhtml format.rxml format.rjs end
This is beautiful to look at! You can tell exactly what it does.
The code has 3 methods, xml, javascript and html, that each take closures.
Each method can selectively call its closure based on the contents of the http accept header!
By Frank Vilhelmsen - 1 tag: rails - Add comment