【问题标题】:Retrieving image for order item with Shoppe gem使用 Shoppe gem 检索订单商品的图像
【发布时间】:2015-06-08 04:38:46
【问题描述】:

无法检索要在当前订单中显示的订单商品图像。

尝试做这样的事情 -

<% order.order_items.each do |item| %>
  <td><%= image_tag item.default_image.path, :width => '200px', :style => "float:right" %></td>
<% end %>

以前有没有人这样做过/有什么想法?我目前正在为“default_image”获取一个未定义的方法。

谢谢!!!!!!!

编辑

    undefined method `default_image' for #<Shoppe::OrderItem:0x007f494834a308>



    app/views/shared/_current_basket.html.erb:14:in `block in 
_app_views_shared__current_basket_html_erb__3066740198477643044_69976360480880'
    app/views/shared/_current_basket.html.erb:13:in `_app_views_shared__current_basket_html_erb__3066740198477643044_69976360480880'
    app/views/orders/show.html.erb:5:in `_app_views_orders_show_html_erb___1356602738108519273_49665800'

default_image 是为 Shoppe::Product 定义的,所以我想我只是在寻找一种类似的方法来检索订单中产品的图像。我似乎在 gem 或 docs 中找不到任何东西,想知道是否有人知道解决方法或我错过的东西!

【问题讨论】:

  • 请显示完整的错误
  • 你在哪里定义了default_image方法?
  • 我自己没有定义它,我正在使用 Shoppe gem。 default_image 是用于在 Shoppe::Product 上调用图像的方法,想知道可以使用什么来获取属于订单的产品的图像。我会在我的问题中澄清这一点

标签: ruby-on-rails ruby gem


【解决方案1】:

试试这个:

"###px", :style => "style:style" %>

【讨论】:

    猜你喜欢
    • 2015-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-02
    • 2019-01-21
    • 1970-01-01
    • 2014-11-15
    • 2018-08-26
    相关资源
    最近更新 更多