Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

recommendable

> 后端框架
Open source

:+1::-1: A recommendation engine using Likes and Dislikes for your Ruby app

1.4K stars0 likes3 views
WebsiteGitHub

About

:+1::-1: A recommendation engine using Likes and Dislikes for your Ruby app

Recommendable

Recommendable is a gem that allows you to quickly add a recommendation engine for Likes and Dislikes to your Ruby application using my version of Jaccardian similarity and memory-based collaborative filtering.

Requirements

  • Ruby >= 1.9.3
  • ActiveRecord, Sequel, DataMapper, Mongoid, or MongoMapper (your models must have an id field)
  • Sidekiq, Resque, or DelayedJob (optional but highly recommended)

Bundling one of the queueing systems above is highly recommended to avoid having to manually refresh users' recommendations. If you bundle Sidekiq, you should also include 'sidekiq-middleware' in your Gemfile to ensure that a user will not get enqueued more than once at a time. If bundling Resque, you should include 'resque-loner' for this. As far as I know, there is no current way to avoid duplicate jobs in DelayedJob. Queueing for Torquebox is also supported.

Installation

Add the following to your application's Gemfile:

ruby
gem 'recommendable'

Please note that you currently must need to place Recommendable below your ORM and queueing system in the Gemfile. If you are using Sidekiq and ActiveRecord, please place gem recommendable below both gem 'rails' and gem 'sidekiq'.

After bundling, you should configure Recommendable. Do this somewhere after you've required it, but before it's actually used. For example, Rails users would create an initializer (config/initializers/recommendable.rb):

…

The values listed above are the defaults. I recommend playing around with the nearest_neighbors setting. A higher value will provide more accurate recommendations at the cost of more time spent generating them.

If your application uses multiple ORMs, you must configure Recommendable to use the correct one. For example:

ruby
Recommendable.configure do |config|
  config.orm = :active_record
end

Important: in case of active_record with id of type uuid, use :active_record_uuid.

Usage

In your model that will be receiving recommendations:

ruby
class User
  recommends :movies, :books, :minerals, :other_things

  # ...
end

To ensure that users' recommendations are processed after they rate items, make sure your bundled queue system is running:

bash
# sidekiq
$ [bundle exec] sidekiq -q recommendable
# resque
$ QUEUE=recommendable [bundle exec] rake environment resque:work
# delayed_job
$ [bundle exec] rake jobs:work

That's it! Please note, however, that currently only one model may receive recommendations.

For more details on how to use Recommendable in your application, check out the detailed guide or see the documentation.

Installing Redis

Recommendable requires Redis to deliver recommendations. The collaborative filtering logic is based almost entirely on set math, and Redis is blazing fast for this.

NOTE: Your Redis database MUST be persistent. All ratings are stored permanently in Redis. If you're worried about Redis losing data, keep backups.

Mac OS X

For Mac OS X users, homebrew is by far the easiest way to install Redis. Make sure to read the caveats after installation!

bash
$ brew install redis

Linux

For Linux users, there is a package on apt-get.

bash
$ sudo apt-get install redis-server
$ redis-server

Redis will now be running on localhost:6379. After a second, you can hit ctrl-\ to detach and keep Redis running in the background.

Why not stars?

I'll let Randall Munroe of XKCD take this one for me:

Links

Build Status Coverage Climate Dependencies gittip

  • Code: git clone git://github.com/davidcelis/recommendable.git
  • Home: http://github.com/davidcelis/recommendable
  • Docs: http://rubydoc.info/gems/recommendable/frames
  • Bugs: http://github.com/davidcelis/recommendable/issues
  • Gems: http://rubygems.org/gems/recommendable

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubyrailsrecommendationsredisruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架