最近我从另一位开发者处获得了一个Rails项目。
当我在Mac上启动Rails服务器时,布局无法正常渲染:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>My title</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<link href="/assets/store/reset.css?body=1" media="screen" rel="stylesheet" type="text/css" />
...
<head>
标记过早关闭,后面是body标记,这使得所有<meta>
标记和样式表都在头外。
然而,当我的一位同事在他的电脑上启动服务器时,布局正确呈现。
这是我的一个布局:
<!doctype html>
<html>
<head>
<%= render 'spree/shared/head' %>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
</head>
<body>
<div id="container">
<%= render 'spree/shared/header' %>
<div id="main" role="main" class="clearfix">
<aside id="sidebar" role="complementary" data-hook>
<%= render 'spree/shared/menu_left' %>
</aside>
<div id="content">
<%= yield %>
</div>
</div>
<%= render 'spree/shared/footer' %>
</div> <!--! end of #container -->
</body>
</html>
答案 0 :(得分:1)
我找到了!错误是由Spree布局和Nokogiri的奇怪行为造成的。 这是解决方案:https://github.com/spree/spree/issues/2633
在我的Gemfile中,我将nokogiri版本设置为1.5.9,如下所示:
gem 'nokogiri', '1.5.9'
答案 1 :(得分:1)