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.
To install, type script/generate rateable [--by_user]
—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>
- Annotate methods
- Zach Inglis
- Nathan Arnold
- Les Hill
- Matt Remsik
- Tim Pope
- Rogie King – CSS for Stars
- Some code from restful_authentication by Rick Olson
Copyright © 2008 Zach Inglis, released under the MIT license