In recent days i have monitored a very strange behaviour of respond_to in IE.I am sharing my experience in hope that somebody might explain it to me. As i cudnt find anything related to this from my best teacher google 😦
I am using edge rails in one of my projects. some where in that i have used respond_to in following way…
def show
respond_to |format| do
format.js {render :partial=>'show'}
format.html {}
end
end
When i checked the response in firefox for html and xml both requests type, it was perfect. But when i checked html response in IE 6 creates a blunder :O.It was returning a js file with the javascript response.
But when i changed the code and placed the html call first and then checked xml call it worked fine in IE too.
def show
respond_to |format| do
format.html {}
format.js {render :partial=>'show'}
end
end
Now can somebody tell me why is this happening and anyone else faced this issue ever?
Procrastinx said:
One possible issue might be because of the ‘Accept’ header that the browser sends. The respond to checks the Accept header of the request object and then corresponds to execute the appropriate action. Firefos generally sends a Accept header which accepts text , html xml combinations , but IE sends something like ‘ */* ‘ . So when the request from IE comes , the first block is rendered beause it fits. Hence which ever is put first is being rendered.
Hope this helps.
—
Procrastinx
Ritu said:
hmmm right thats what we have figured out lately.
But isn’t it one more addition in the long list of bugs in IE?? or is it a problem with respond_to? 8-|
Procrastinx said:
Well im not that good at rails to comment if its a problem with respond_to. But considering that it works with other browsers , we can consider it to be a IE bug. One possible solution is to have a :before_filter ‘set_proper_accept_header’ in the controller and in the filter method do a request.env[“HTTP_ACCEPT”] = “application/xml” if the user agent is IE.
Hope this helps.
_
Procrastinx
Pingback: Rails’ respond_to method | info.michael-simons.eu
Pingback: Wejoinin Blog » Blog Archive » RSS feeds gone haywire!
Pingback: Workaround for IE Overly Accepting in Rails’ respond_to format -- Garrick Van Buren .com
Jake Scruggs said:
Thanks – this really helped me out.
Paula said:
Thanks you. It is a really helpful post.
Pingback: Braxton in Austin » Rails respond_to issues when using IE
Ritu said:
I am amazed to see after so many years the thing hasn’t been resolved in respond_to , considering IE is the most widely used browser. Its the latest on the same issue http://www.chrissearle.org/node/565.
right hotmail support said:
Wonderful items from you, man. I have take note your stuff prior to and you’re simply extremely great. I really like what you’ve received here, really like what you are stating and the best
way during which you assert it. You make it entertaining
and you still care for to keep it sensible. I cant wait to learn
much more from you. That is actually a great site.
blog.lacasaaccesible.com said:
I like the valuable information you provide in your articles.
I’ll bookmark your weblog and check again here regularly. I’m quite sure I will learn many new stuff
right here! Best of luck for the next!