maglevhq / maglev-core

Ruby on Rails website builder
https://www.maglev.dev
MIT License
273 stars 47 forks source link

fix(collection_items): 'TypeError - nil is not a symbol nor a string' #15

Closed patdec closed 2 years ago

patdec commented 3 years ago

Below result of binding,pry

From: /home/patrice/Working/docker/workspace/maglev/maglev-mit/app/services/maglev/fetch_collection_items.rb:75 Maglev::FetchCollectionItems#build_item:

    73: def build_item(original_item)
    74:   binding.pry
 => 75:   return nil unless original_item
    76: 
    77:   Item.new(
    78:     original_item.id,
    79:     original_item[label_field],
    80:     original_item.respond_to?(image_field) ? original_item.public_send(image_field) : nil,
    81:     original_item
    82:   )
    83: end

[1] pry(#<Maglev::FetchCollectionItems>)> original_item
=> #<Spree::Product:0x000000000dda7750
 id: 24293,
 name: "Nestin | 10C2",
 available_on: Mon, 10 May 2021 00:01:34.988817000 CEST +02:00,
 deleted_at: nil,
 slug: "nestin-10c2",
 meta_description: nil,
 meta_keywords: nil,
 tax_category_id: 4,
 shipping_category_id: 1,
 created_at: Mon, 10 May 2021 00:01:35.047189000 CEST +02:00,
 updated_at: Mon, 10 May 2021 00:01:35.363698000 CEST +02:00,
 promotionable: true,
 meta_title: nil,
 discontinue_on: nil,
 synonyms: nil,
 description: nil>
[2] pry(#<Maglev::FetchCollectionItems>)> original_item.id
=> 24293
[3] pry(#<Maglev::FetchCollectionItems>)> original_item[label_field]
=> "Nestin | 10C2"
[4] pry(#<Maglev::FetchCollectionItems>)> original_item.respond_to?(image_field)
TypeError: nil is not a symbol nor a string