Possible Duplicates:
What is the best way to learn Ruby?
Explain Iterator Syntax on Ruby on Rails
I’m still learning ruby, ruby on rails and such. I’m getting better at understanding all the ruby and rails syntax but this one has me a little stumped.
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @contact_lists }
end
respond_to is a method that takes a proceedure, I think. The two formats look like they may be method calls too, but I don’t know.
respond_tois a method which takes block. The block takes one argument, which here is calledformat.Now you call two methods on
format.htmlwhich you call without arguments. Andxmlwhich you call with a block.This block takes no arguments and contains a call to the render method with a hash as an argument. The hash contains the key
:xmland the value@contact_lists.