Project

spleen

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ratings model solution for Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.6.0
~> 2.4.0
~> 1.3
 Project Readme

Ratings for Rails 3

gem 'spleen'

bundle exec rails generate spleen:install

Usage:

# edit app/models/article.rb:
  extend Spleen
  spleen(:dependent => :destroy)

# add Article to RATEABLE_TYPES on app/models/rating.rb:
  RATEABLE_TYPES = %w{Article}

a = Article.create(:title => 'test')
a.rate(1, User.last)
a.ratings # => [#<Rating id: 1, ...]
a.average_rate # => 1.0
a.sum_rate # => 1
a.count_rate # => 1

Tests

bundle exec ruby test/*_test.rb

TODO

  • tests
  • documentation

LICENSE

The MIT License

Copyright (c) 2011 Laurent Arnoud laurent@spkdev.net