Skip to content

oleriesenberg/is_rateable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

is_rateable

Currently star buttons are a put request, not a post request like they should be due to time constraints. Should be fixed in a future version.

Patches welcome! I do test my own stuff but until I find a nice and easy way to include rspec in plugins, they won’t come with the specs.

Usage

To install, type script/generate rateable [--by_user]

Options

—by-user will associate your ratings to a user model. Hopefully you’ve got one already.

In your model.
<pre> is_rateable :upto => 5 # it defaults :upto => 5 </pre>

In your view.
<pre> render_rating(@book, :interactive_stars) render_rating(@book) # If you want to also see 1/5 Stars </pre>

If a user rates more than twice, it will delete their older rating and put up a new rating.

Add a method to your books_controller like so:
<pre> def rate @book = Book.find(params[:id]) if @source.rate(params[:rating].to_i, :ip => request.remote_ip) respond_to do |format| format.js end end end </pre>

Todo

  • Annotate methods

Credits

Copyright © 2008 Zach Inglis, released under the MIT license

About

Ratings for your model. With AJAX!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%