我正在尝试使用deface向spree admin添加字段。我按照他们的教程,但他们使用字符串插入html。我试图将该字符串移动到html.erb
文件中并将源引用为部分,并出现以下错误。
undefined method `empty?' for nil:NilClass
注意:所有内容均以狂欢扩展
完成# /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 => '[data-hook="admin_product_form_price"]',
:text => "<%= f.field_container :sale_price do %>
<%= f.label :sale_price, raw(Spree.t(:sale_price) + content_tag(:span, ' *')) %>
<%= f.text_field :sale_price, :value =>
number_to_currency(@product.sale_price, :unit => '') %>
<%= f.error_message_on :sale_price %>
<% end %>")
# /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 => '[data-hook="admin_product_form_price"]',
:partial => 'simple_sale')
# /overrides/_simple_sale.html.erb
<div>
<%= f.field_container :sale_price do %>
<%= f.label :sale_price, raw(Spree.t(:sale_price) + content_tag(:span, ' *')) %>
<%= f.text_field :sale_price, :value =>
number_to_currency(@product.sale_price, :unit => '') %>
<%= f.error_message_on :sale_price %>
<% end %>
</div>
答案 0 :(得分:0)
我的猜测是你需要在views文件夹中使用partial而不是覆盖文件夹 - / overrides是针对.rb文件 - 部分和其他视图文件需要放在/ views文件夹中:/ views /共享或某事。