Spree deface覆盖教程

Ste*_*e Q 0 ruby-on-rails spree ruby-on-rails-4

我正在关注Spree deface覆盖开发人员指南:http://guides.spreecommerce.com/developer/deface_overrides_tutorial.html

我的代码完全匹配它们,但我一直收到这个错误.我环顾四周,但我没有看到其他人遇到这个问题或类似的东西:

Spree:模块的未定义方法`content_tag'

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

这是我的代码:

应用程序/重写/ 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 %>
   ")
Run Code Online (Sandbox Code Playgroud)

应用程序/模型/大礼包/ product_decorator.rb

module Spree
  Product.class_eval do
    delegate_belongs_to :master, :sale_price
  end
end
Run Code Online (Sandbox Code Playgroud)

gma*_*all 6

您收到错误是因为未指定Spree.t(:sale_price)的翻译.这是失败的,因为Rails 4.0.2 对I18n API进行了一些更改.你有几个选择.

  1. 添加缺失标记的翻译,并记住此content_tag问题是由这个疯狂的错误引起的.
  2. 降级到Rails 4.0.0(不推荐)
  3. 将狂欢升级到2-1稳定分支(或等到2.1.4发布)
  4. 应用这一变化对当地的狂欢安装.它应该纠正这个问题.

任何这些应该让你再次工作.