Удалить ключ из хеша - PullRequest
       23

Удалить ключ из хеша

0 голосов
/ 15 апреля 2020

Я вообще не знаю Ruby, но я пытаюсь расширить этот плагин Jekyll . Автор упоминает просто удалить ключ из записи. Я пытался использовать функцию delete, но она, похоже, не работает.

Вот мой код:

module Jekyll
  module Algolia
   module Hooks
     def self.before_indexing_each(record, node, context)
      record.delete(":gallery")
      record
     end
   end
  end
end

Я уверен, что здесь не хватает чего-то очень простого, но любой идеи были бы отличными. Ха sh выглядит следующим образом:

{:html=>"<p>Captain Brieux is a character in the 1974 film, The Island at the Top of World. Portrayed by Jacques Marin, he is a French inventor who pilots an expedition in a French dirigible name the Hyperion (a model can be found at Disneyland Paris).</p>", :content=>"Captain Brieux is a character in the 1974 film, The Island at the Top of World. Portrayed by Jacques Marin, he is a French inventor who pilots an expedition in a French dirigible name the Hyperion (a model can be found at Disneyland Paris).", :headings=>[], :custom_ranking=>{:position=>0, :heading=>100}, :title=>"Captain Brieux", :membership=>"Unconfirmed", :portrait=>"/gallery/members/captain-brieux/portrait.jpg", :attractions=>["_attractions/skipper-canteen.md"], :parks=>["Magic Kingdom", "Disneyland Paris"], :gallery=>[], :collection=>"members", :tags=>[], :categories=>[], :excerpt_html=>"<p>Captain Brieux is a character in the 1974 film, The Island at the Top of World. Portrayed by Jacques Marin, he is a French inventor who pilots an expedition in a French dirigible name the Hyperion (a model can be found at Disneyland Paris).</p>", :excerpt_text=>"Captain Brieux is a character in the 1974 film, The Island at the Top of World. Portrayed by Jacques Marin, he is a French inventor who pilots an expedition in a French dirigible name the Hyperion (a model can be found at Disneyland Paris).", :slug=>"captain-brieux", :type=>"document", :url=>"/sea/members/captain-brieux"}

1 Ответ

1 голос
/ 15 апреля 2020

проблема в вашем коде в том, что вы отправляете символ в виде строки, просто удалите "" из параметра удаления

module Jekyll
  module Algolia
   module Hooks
     def self.before_indexing_each(record, node, context)
      record.delete(:gallery)
      record
     end
   end
  end
end
...