Ruby on Rails页面为何不是纯文本?
- 内容介绍
- 文章标签
- 相关推荐
本文共计442个文字,预计阅读时间需要2分钟。
我在开发一个Rails应用程序,但使用Internet Explorer访问时遇到了问题。Firefox和Safari都能正常显示页面。当使用Internet Explorer时,某些页面会尝试下载页面而不是显示它。
我正在开发一个Rails应用程序,但是在使用Internet Explorer访问它时发现了一个问题.Firefox和Safari可以显示页面.
通过,当使用Internet Explorer时,在某些页面中它会尝试下载页面,而不是显示它.
我不知道会发生什么.
这是我的application.html.erb的html标题:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="www.w3.org/1999/xhtml"> <head id="otzee_header_scripts"> <meta www.google.com/jsapi"></script> </head>
但我不认为它与application.html.erb有关,因为有些页面显示正常,而其他页面则由ie下载.
对于可能导致这种情况的原因有任何疑问吗?或者如何解决?
先感谢您
UPDATE
我现在知道这与标题有关,它发送为mime内容类型text / javascript而不是text / html.
但我不知道为什么.
这是控制器代码,万一有人可以指出我的错误,请.
def index respond_to do |format| format.js do if params[:bookmarks] != 0 @games_infos = current_user.games_info_bookmarks params[:page], 8 @bookmarks = 1 else @games_infos = current_user.games_info_collection params[:page], false, 8 @bookmarks = 0 end end format.html do @invites = current_user.friends_pending @whats_new = WhatsNew.find_user_network_updates @me, 1, 13 @games_infos = @me.games_info_bookmarks params[:page], 8 @bookmarks = @games_infos.size @games_infos = @me.games_info_collection(params[:page], false, 8) unless @bookmarks > 0 @friends = @me.friends_on_off @high_scores = @me.high_scores end end end
Obs:firebug显示Content-Type text / html; firefox上的charset = utf-8,Fiddler显示Content-Type text / javascript; Internet Explorer上的charset = utf-8.
我总是把format.html放在第一位.这样,当IE发送一个奇怪的接受标头,如’/’时,它将呈现它击中的第一个.在你的情况下,IE说它正在寻找任何东西,所以你发送它js.首先放置你的format.html块,你将是金色的.(有关详细信息,请参阅my answer here)
本文共计442个文字,预计阅读时间需要2分钟。
我在开发一个Rails应用程序,但使用Internet Explorer访问时遇到了问题。Firefox和Safari都能正常显示页面。当使用Internet Explorer时,某些页面会尝试下载页面而不是显示它。
我正在开发一个Rails应用程序,但是在使用Internet Explorer访问它时发现了一个问题.Firefox和Safari可以显示页面.
通过,当使用Internet Explorer时,在某些页面中它会尝试下载页面,而不是显示它.
我不知道会发生什么.
这是我的application.html.erb的html标题:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="www.w3.org/1999/xhtml"> <head id="otzee_header_scripts"> <meta www.google.com/jsapi"></script> </head>
但我不认为它与application.html.erb有关,因为有些页面显示正常,而其他页面则由ie下载.
对于可能导致这种情况的原因有任何疑问吗?或者如何解决?
先感谢您
UPDATE
我现在知道这与标题有关,它发送为mime内容类型text / javascript而不是text / html.
但我不知道为什么.
这是控制器代码,万一有人可以指出我的错误,请.
def index respond_to do |format| format.js do if params[:bookmarks] != 0 @games_infos = current_user.games_info_bookmarks params[:page], 8 @bookmarks = 1 else @games_infos = current_user.games_info_collection params[:page], false, 8 @bookmarks = 0 end end format.html do @invites = current_user.friends_pending @whats_new = WhatsNew.find_user_network_updates @me, 1, 13 @games_infos = @me.games_info_bookmarks params[:page], 8 @bookmarks = @games_infos.size @games_infos = @me.games_info_collection(params[:page], false, 8) unless @bookmarks > 0 @friends = @me.friends_on_off @high_scores = @me.high_scores end end end
Obs:firebug显示Content-Type text / html; firefox上的charset = utf-8,Fiddler显示Content-Type text / javascript; Internet Explorer上的charset = utf-8.
我总是把format.html放在第一位.这样,当IE发送一个奇怪的接受标头,如’/’时,它将呈现它击中的第一个.在你的情况下,IE说它正在寻找任何东西,所以你发送它js.首先放置你的format.html块,你将是金色的.(有关详细信息,请参阅my answer here)

