Alex Kale

Joined

10 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Searchkick search_data not working

Was there any change to you code above? I'm having the same issue.

class Recipient < ActiveRecord::Base

  searchkick text_start: [:recipient_name]

  belongs_to :category

  def search_data
    {
      recipient_name: recipient_name,
      city: city,
      state: state,
      country: country,
      category_name: category.name
    }
  end
end

after running rake searchkick:reindex:all, I get the following error

Reindexing Recipient...
rake aborted!
NoMethodError: undefined method `name' for nil:NilClass
/Users/alexkale/Sites/dev/prnewswire/prn_product/app/models/recipient.rb:47:in `search_data'
Tasks: TOP => searchkick:reindex:all
(See full trace by running task with --trace)
logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2022 GoRails, LLC. All rights reserved.