In Ruby on Rails, why http://localhost:3000/foobars/alt/1.xml not work?
In Ruby on Rails,
http://localhost:3000/foobars/alt/1
works
but
http://localhost:3000/foobars/alt/1.xml
doesn't work.
config/route.rb
is
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
so supposedly 开发者_运维问答it supports an id.format
in the URL?
Ensure that your controller action has a respond to block that supports XML:
def alt
@object = ...
respond_to do |format|
format.html
format.xml { render :xml => @object.to_xml }
end
end
精彩评论