Ruby on rails 如何通过GraphQL Ruby获取回形针图像URL
我正试图通过以下途径提供该商品的回形针缩略图变体:Ruby on rails 如何通过GraphQL Ruby获取回形针图像URL,ruby-on-rails,graphql,paperclip,graphql-ruby,Ruby On Rails,Graphql,Paperclip,Graphql Ruby,我正试图通过以下途径提供该商品的回形针缩略图变体: app/graphql/types/item_type.rb: class Types::ItemType < Types::BaseObject description 'An item' field :title, String, null: false field :thumbnail_image, String, null: true def thumbnail_image item.image.url(
app/graphql/types/item_type.rb
:
class Types::ItemType < Types::BaseObject
description 'An item'
field :title, String, null: false
field :thumbnail_image, String, null: true
def thumbnail_image
item.image.url(:thumb_2x)
end
end
classtypes::ItemType
这只会导致以下错误:
"message": "undefined local variable or method `item' for #<Types::ItemType:0x00007ff3f1dbc4e0>"
“消息”:“未定义的局部变量或#的'item'方法”
什么是让它工作的正确方法?我需要一个解析器吗?想好了,我需要这样做:
def thumbnail_image
object.image.url(:thumb_2x)
end