0
爲什麼渲染渲染爲什麼:locals
當它從js.erb
文件調用不起作用?裏面js.erb當地人不工作
這個我create.js.erb
:
$("#div").before("<%= escape_javascript(render("/admin/products/variant_image_preview", :locals => {:image => @variant_image})) %>");
variant_image_preview.html.erb
:
<div id="variant_image_<%= image.id %>">
<%= image_tag image.image_url(:thumb), width: 114, height: 88 %>
<% form_name = "product[variants_attributes][1][images_attributes][#{Time.now.to_f}]" %>
<input type="hidden" value="<%= image.id %>" name="<%= form_name %>[id]">
<a id="<%= image.id %>" class="remove_image" title="Remover imagem">
<img src="/assets/bg_close.png" alt="Remover imagem">
</a>
</div>
在variant_image_preview.html.erb的第一線,我得到這個錯誤:
NameError - undefined local variable or method `image' for #<#<Class:0x0000000f4f6e88>:0x000000101332c8>:
在計算器上的一些帖子說該代碼應該可以工作。任何幫助?