# Problem in understanding respond\_to in rails 2.0 and above

**URL:** <https://www.ruby-forum.com/t/problem-in-understanding-respond-to-in-rails-2-0-and-above/165018>\
**Category:** Rails\
**Created:** [April 8, 2009, 9:52am UTC](https://www.ruby-forum.com/t/problem-in-understanding-respond-to-in-rails-2-0-and-above/165018 "2009-04-08T09:52:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 8, 2009, 9:52am UTC](https://www.ruby-forum.com/t/problem-in-understanding-respond-to-in-rails-2-0-and-above/165018/1 "2009-04-08T09:52:56Z")

</div>

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
