Ruby on rails 如何覆盖在Ruby on Rails Spree Commerce应用程序中引起问题的文件?
在从Rails 3更新到Rails 4并安装了之后,我在Ruby on rails 如何覆盖在Ruby on Rails Spree Commerce应用程序中引起问题的文件?,ruby-on-rails,ruby,twitter-bootstrap,overriding,spree,Ruby On Rails,Ruby,Twitter Bootstrap,Overriding,Spree,在从Rails 3更新到Rails 4并安装了之后,我在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 lin
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
#<#<Class:0x000000070139c8>:0x000000068d7da8>
Extracted source (around line #1):
1
2
3
4
<% if image %>
<%= image_tag image.attachment.url(:product), :itemprop => "image" %>
<% else %>
<%= product_image(@product, :itemprop => "image") %>
Trace of template inclusion: []app/views/spree/products/show.html.erb
Rails.root: []/rails/releases/20140118194836
Spree::Products#show中的名称错误
显示[]/ruby/1.9.1/bundler
/gems/spree_bootstrap-a529d6bb6db0/app/views/spree/products/_image.html.erb where line
#1提出:
未定义的局部变量或方法“image”
#
提取的源(第1行附近):
1.
2.
3.
4.
“图像”%>
“图像”)%%>
模板包含跟踪:[]app/views/spree/products/show.html.erb
Rails.root:[]/Rails/releases/201401118194836
我知道。如果我想更改文件,我需要覆盖这些文件
所以我想更改那里的代码,所以我在本地添加了一个具有相同路径和名称的文件(app/views/spree/products/_image.html.erb
)和所需的新代码。然后我部署了它,当我ssh到服务器中时,我看到了这个文件。但在网站上,我仍然得到同样的错误。由于模板包含的痕迹表明它来自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
。错误在GitHub问题中所述的\u图像
部分中。答案在GitHub问题的链接中。因此,您可以完全删除第一个图像\标记image.attachment.url(:product)
块,也可以将其替换为
。问题主要是如何替换代码?:)谢谢这正是我所做的,但似乎没有帮助。我又看了一遍,意识到我做了mkdir产品->touch\u image.html.erb
而不是mkdir产品->cd产品->touch\u image.html.erb
。美好的嗯,这就是答案,所以请投赞成票。:)