Spree:在Spree :: Home #index

时间:2015-09-30 02:43:40

标签: ruby ruby-on-rails-4 spree

我试图更改列出项目的首页的外观但我收到错误。我是否正确使用污损来改变它?它告诉我<%= link_to small_image(product, itemprop: "image"), url, itemprop: 'url' %>给我错误,如果我删除那么没有图片。我该怎么办?

update_products.rb

Deface::Override.new(:virtual_path =>"spree/shared/_products",
                     :name => "change site",
                     :replace =>"#products",
                     :text => '



<%
  paginated_products = @searcher.retrieve_products if params.key?(:keywords)
  paginated_products ||= products
%>

<% content_for :head do %>
  <% if paginated_products.respond_to?(:num_pages) %>
    <%= rel_next_prev_link_tags paginated_products %>
  <% end %>
<% end %>

<div data-hook="products_search_results_heading">
  <% if products.empty? %>
    <div data-hook="products_search_results_heading_no_results_found">
      <%= Spree.t(:no_products_found) %>
    </div>
  <% elsif params.key?(:keywords) %>
    <div data-hook="products_search_results_heading_results_found">
      <h6 class="search-results-title"><%= Spree.t(:search_results, keywords: h(params[:keywords])) %></h6>
    </div>
  <% end %>
</div>

<% if products.any? %>
  <div id="products" class="row" data-hook>
    <% products.each do |product| %>
      <% url = spree.product_url(product, taxon_id: @taxon.try(:id)) %>
      <div id="product_<%= product.id %>" class="col-md-3 col-sm-6 product-list-item" data-hook="products_list_item" itemscope itemtype="https://schema.org/Product">
        <div class="panel panel-default">
          <% cache(@taxon.present? ? [I18n.locale, current_currency, @taxon, product] : [I18n.locale, current_currency, product]) do %>
            <div class="panel-body text-center product-body">
              <br/>
<%= link_to small_image(product, itemprop: "image"), url, itemprop: 'url' %>
            </div>
            <div class="panel-footer text-center">
              <span itemprop="offers" itemscope itemtype="https://schema.org/Offer">
                <span class="price selling lead" itemprop="price"><%= display_price(product) %></span>
              </span>
            </div>
          <% end %>
        </div>
      </div>
    <% end %>
    <% reset_cycle("classes") %>
  </div>
<% end %>

<% if paginated_products.respond_to?(:num_pages) %>

<% end %>
')

1 个答案:

答案 0 :(得分:2)

url <%= link_to small_image(product, itemprop: "image"), url, itemprop: "url" %>的一个小引号问题,请检查此代码: -

Deface::Override.new(:virtual_path =>"spree/shared/_products",
                     :name => "change site",
                     :replace =>"#products",
                     :text => '



<%
  paginated_products = @searcher.retrieve_products if params.key?(:keywords)
  paginated_products ||= products
%>

<% content_for :head do %>
  <% if paginated_products.respond_to?(:num_pages) %>
    <%= rel_next_prev_link_tags paginated_products %>
  <% end %>
<% end %>

<div data-hook="products_search_results_heading">
  <% if products.empty? %>
    <div data-hook="products_search_results_heading_no_results_found">
      <%= Spree.t(:no_products_found) %>
    </div>
  <% elsif params.key?(:keywords) %>
    <div data-hook="products_search_results_heading_results_found">
      <h6 class="search-results-title"><%= Spree.t(:search_results, keywords: h(params[:keywords])) %></h6>
    </div>
  <% end %>
</div>

<% if products.any? %>
  <div id="products" class="row" data-hook>
    <% products.each do |product| %>
      <% url = spree.product_url(product, taxon_id: @taxon.try(:id)) %>
      <div id="product_<%= product.id %>" class="col-md-3 col-sm-6 product-list-item" data-hook="products_list_item" itemscope itemtype="https://schema.org/Product">
        <div class="panel panel-default">
          <% cache(@taxon.present? ? [I18n.locale, current_currency, @taxon, product] : [I18n.locale, current_currency, product]) do %>
            <div class="panel-body text-center product-body">
              <br/>
<%= link_to small_image(product, itemprop: "image"), url, itemprop: "url" %>
            </div>
            <div class="panel-footer text-center">
              <span itemprop="offers" itemscope itemtype="https://schema.org/Offer">
                <span class="price selling lead" itemprop="price"><%= display_price(product) %></span>
              </span>
            </div>
          <% end %>
        </div>
      </div>
    <% end %>
    <% reset_cycle("classes") %>
  </div>
<% end %>

<% if paginated_products.respond_to?(:num_pages) %>

<% end %>
')