-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Description
Hey, for some reason when you run the following:
# models/user.rb
class User < ApplicationRecord
recommends :listings, :categories, :tags, :brands
endyou get the following error after performing an action, in the Sidekiq logs
0 WARN: NoMethodError: undefined method `count' for nil:NilClass
2020-04-04T20:15:47.344Z pid=93820 tid=oxbyb6dk0 WARN: /Library/Ruby/Gems/2.6.0/gems/recommendable-2.2.2/lib/recommendable/helpers/calculations.rb:106:in `update_recommendations_for'The line points to this line in the helpers/calculations.rb file:
nearest_neighbors = Recommendable.config.nearest_neighbors || Recommendable.config.user_class.countwhich suggests that the issue may arise from the config.nearest_neighbors being set to nil and the config.user_class not being set.
However, when you set the config.user_class = User, the application crashed instantly with a bunch of weird errors.
My config/initializers/recommendable.rb looks like:
Recommendable.configure do |config|
# Recommendable's connection to Redis
config.redis = Redis.new
# Whether or not to automatically enqueue users to have their recommendations
# refreshed after they like/dislike an item
config.auto_enqueue = true
endMetadata
Metadata
Assignees
Labels
No labels