Tushar Gandhi
2009-Apr-08 07:52 UTC
problem in understanding respond_to in rails 2.0 and above
Hi,
I am using rails 2.2.
I have created a controller using "ruby script/generate scaffold
person".
This created the code like this.
def index
@people = Person.find(:all)
respond_to do |format|
format.html
format.xml { render :xml => @people.to_xml }
end
end
I am new in rails 2.0 and above. I worked on rails 1.2.3. I an not able
to understand what is the use of
"respond_to do |format|
format.html
format.xml { render :xml => @people.to_xml }
end" this code.
Can anyone focus for me?
Help appreciated.
Also there are some code like this
"respond_to do |format|
format.html
format.js
format.xml { render :xml => @people.to_xml }
end"
Thanks,
Tushar
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---