【问题标题】:Spree deface override tutorial狂欢破坏覆盖教程
【发布时间】:2014-01-11 08:33:33
【问题描述】:

我正在关注 Spree deface overrides 开发者指南:http://guides.spreecommerce.com/developer/deface_overrides_tutorial.html

我的代码与他们的完全匹配,但我不断收到此错误。我环顾四周,但我没有看到其他人有这个问题或任何类似的问题:

Spree:Module 的未定义方法 `content_tag'

我正在运行 Rails 4.0.2 和 ruby​​ 1.9.3(可能教程没有针对 rails 4 进行更新?)

这是我的代码:

app/overrides/add_sale_price_to_product_edit.rb

Deface::Override.new(:virtual_path => 'spree/admin/products/_form',
  :name => 'add_sale_price_to_product_edit',
  :insert_after => "erb[loud]:contains('text_field :price')",
  :text => "
    <%= f.field_container :sale_price do %>
      <%= f.label :sale_price, raw(Spree.t(:sale_price)) %><span>*</span>
      <%= f.text_field :sale_price, :value =>
        number_to_currency(@product.sale_price, :unit => '') %>
      <%= f.error_message_on :sale_price %>
    <% end %>
   ")

app/models/spree/product_decorator.rb

module Spree
  Product.class_eval do
    delegate_belongs_to :master, :sale_price
  end
end

【问题讨论】:

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


    【解决方案1】:

    您收到错误是因为 Spree.t(:sale_price) 的翻译未指定。这是失败的,因为 Rails 4.0.2 做了一些changes to the I18n API 。你有几个选择。

    1. 为缺少的标签添加翻译,并记住这个 content_tag 问题是由这个疯狂的错误引起的。
    2. 降级到 Rails 4.0.0(不推荐)
    3. 大礼包升级到 2-1-stable 分支(或等到 2.1.4 发布)
    4. this change 应用于您的本地Spree 安装。它应该可以纠正这个问题。

    其中任何一个都应该让你再次工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-08
      • 1970-01-01
      • 1970-01-01
      • 2017-06-02
      相关资源
      最近更新 更多