使用deface覆盖spree视图

时间:2015-03-02 09:19:29

标签: spree overrides deface

我试图使用Deface覆盖一些视图,但我在控制台中收到了此错误和警告:

Deface: 1 overrides found for 'spree/shared/_header'
Deface: 'header_background' matched 1 times with 'div#spree-header'
Deface: [WARNING] No :original defined for 'header_background', you should change its definition to include:
 :original => '870f2cc85da3717b7c721a3e99245cf65b607a19' 
Deface: [WARNING] Circular sequence dependency includes override named: 'auth_shared_login_bar' on 'spree/shared/_nav_bar'.
Deface: 2 overrides found for 'spree/shared/_nav_bar'
Deface: 'main_menu' matched 1 times with 'nav#top-nav-bar'
Deface: [WARNING] No :original defined for 'main_menu', you should change its definition to include:
 :original => 'a35cdc6247d04a90fc0aefc58f068ae2b3923eab' 
Deface: 'auth_shared_login_bar' matched 1 times with 'li#search-bar'
Deface: [ERROR] The original source for 'auth_shared_login_bar' has changed, this override should be reviewed to ensure it's still valid.
Deface: [WARNING] Circular sequence dependency includes override named: 'auth_shared_login_bar' on 'spree/shared/_nav_bar'.
Deface: [WARNING] Circular sequence dependency includes override named: 'auth_shared_login_bar' on 'spree/shared/_nav_bar'.
Deface: 1 overrides found for 'spree/shared/_main_nav_bar'
Deface: 'home-link' matched 1 times with 'li#home-link'
Deface: [WARNING] No :original defined for 'home-link', you should change its definition to include:
 :original => '79d342a6fd7281d8499d3a5ee5480f416f733e98'

这些是我的覆盖文件:

update_ordes.rb

Deface::Override.new(:virtual_path =>"spree/orders/edit",
                     :name => "continue_shopping",
                     :replace => "erb[loud]:contains('link_to t(:continue_shopping), products_path')",
                     :text => "<%= link_to t(:continue_shopping), products_path, :class => 'btn btn-primary' %>")

auth_login_bar.rb

Deface::Override.new(:virtual_path => "spree/shared/_nav_bar",
                     :name => "auth_shared_login_bar",
                     :insert_before => "li#search-bar",
                     :partial => "spree/shared/login_bar",
                     :disabled => false, 
                     :original => 'eb3fa668cd98b6a1c75c36420ef1b238a1fc55ac',
                     :sequence => {:after => "auth_shared_login_bar"})

update_header.rb

Deface::Override.new(:virtual_path => "spree/shared/_header",
                 :name => "header_background",
                 :replace => "div#spree-header",
                 :text => '<div class="container">
                 <header id="header" class="row" data-hook>

  <%= render :partial => "spree/shared/nav_bar" %>
  <%= render :partial => "spree/shared/main_nav_bar" if store_menu? %>
</header></div>')

update_menu.rb

Deface::Override.new(:virtual_path => "spree/shared/_main_nav_bar",
                 :name => "home-link",
                 :remove => "li#home-link")

Deface::Override.new(:virtual_path =>"spree/shared/_nav_bar",
                     :name => "main_menu",
                     :replace =>"nav#top-nav-bar",
                     :text => '<nav id="top-nav-bar" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <div id="logo"><%= logo %></div>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav navbar-right"  data-hook>


    <li id="search-bar" data-hook>
      <%= render :partial => "spree/shared/search" %>
    </li>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container -->
</nav>'
)

我还添加了gem&#39; spree_bootstrap_frontend&#39; 我没有对spree / orders / edit文件进行更改

我应该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

Original

no original警告正是他们所说的。您需要将original选项添加到update_header.rb文件中。此外,original的{​​{1}}哈希值已过时,因此您需要更新该哈希值,或更改为您正在使用的确切原始块。

auth_shared_login_bar

序列选项用于了解覆盖的顺序,当应用不同的覆盖并且顺序很重要时。但是,在Sequence中,您将序列引用给自身,从而导致循环依赖。您应该删除它或者提供任何其他依赖的覆盖(例如auth_shared_login_bar