星期五, 6月 05, 2009

RoR的restful_authentication plugin在IE 8上的問題


今天網站在作測試時, 有人反映IE 8無法正確的導到login畫面, 而會跳出這個畫面, 找到原因是因為IE 8有時會送出空的HTML Accept header而使得程式跑到format.any這個區塊, 因此會造成跟其他瀏覽器不一樣的情況.

一個簡單的修改方法是將lib/authenticated_system.rb中原本這段
def access_denied
respond_to do |format|
format.html do
store_location
redirect_to new_session_path
end
format.any do
request_http_basic_authentication 'Web Password'
end
end
end

改為下面這樣, 因為我們暫時沒有其他的format, 所以使用format.any來作判斷
 def access_denied
respond_to do |format|
format.any do
store_location
redirect_to new_session_path
end
end
end
這樣就可以正確的進入login畫面囉.

沒有留言: