Skip to content

Instantly share code, notes, and snippets.

@olvado
Created April 22, 2009 11:19
Show Gist options
  • Save olvado/99735 to your computer and use it in GitHub Desktop.
Save olvado/99735 to your computer and use it in GitHub Desktop.
Example of Act As Recomendable
class Book < ActiveRecord::Base
has_many :user_books
has_many :users, :through => :user_books
end
class UserBook < ActiveRecord::Base
belongs_to :book
belongs_to :user
end
class User < ActiveRecord::Base
has_many :user_books
has_many :books, :through => :user_books
acts_as_recommendable :books, :through => :user_books
end
user = User.find(:first)
user.similar_users #=> [...]
user.recommended_books #=> [...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment