如何覆盖在Ruby on Rails狂欢商务应用程序中导致问题的文件?

从Rails 3更新到Rails 4并为Spree安装Bootstrap gem后,我在app/views/spree/products/_image.html.erb收到错误。 单击主页上产品的图像后,页面如下所示:

  NameError in Spree::Products#show Showing []/ruby/1.9.1/bundler /gems/spree_bootstrap-a529d6bb6db0/app/views/spree/products/_image.html.erb where line #1 raised: undefined local variable or method `image' for #<#:0x000000068d7da8> Extracted source (around line #1): 1 2 3 4   "image" %>   "image") %> Trace of template inclusion: []app/views/spree/products/show.html.erb Rails.root: []/rails/releases/20140118194836 

我知道这可以通过更改破坏它的文件来解决,只包含 "image") %> 。 我了解到如果我想让它们改变,我需要覆盖文件。

所以我想在那里更改代码,我在本地添加了一个具有相同路径和名称的文件( app/views/spree/products/_image.html.erb )和所需的新代码。 然后我部署了它,当我进入服务器时,我看到了文件。 但在网站上我仍然得到同样的错误。 由于模板包含的痕迹说它来自app/views/spree/products/show.html.erb我也将该文件更改为它,但我仍然在服务器上看到相同的代码。

我该如何解决?

在项目文件夹中创建此文件 ,然后将内容替换为:

 <%= product_image(@product, :itemprop => "image") %> 

或者用这个:

 <% if local_assigns[:image].present? && image %> <%= image_tag image.attachment.url(:product), :itemprop => "image" %> <% else %> <%= product_image(@product, :itemprop => "image") %> <% end %> 

顺便说一句,如果您只是为了摆脱错误,我认为没有必要覆盖app/views/spree/products/show.html.erb 。 错误在_image部分内,如GitHub问题中所述。