Rails布局无法正确呈现?

时间:2014-06-30 12:49:21

标签: html ruby-on-rails ruby layout ruby-on-rails-4

最近我从另一位开发者处获得了一个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>

2 个答案:

答案 0 :(得分:1)

我找到了!错误是由Spree布局和Nokogiri的奇怪行为造成的。 这是解决方案:https://github.com/spree/spree/issues/2633

在我的Gemfile中,我将nokogiri版本设置为1.5.9,如下所示:

gem 'nokogiri', '1.5.9'

答案 1 :(得分:1)

这显然是一个已知问题,记录在案here。在那个帖子中,Ryan Bigg说:

  

我认为使用Nokogiri和旧版本存在问题   libxml。你可以请确保你绝对使用   最新的稳定版libxml?

尝试更新您的libxml版本,看看是否有所作为。