I am having some problem figuring out how to use the rateable plugin. i
followed as close as the directions located at
http://www.naffis.com/blog/articles/2006/08/31/rails-ajax-star-rating-system
but there seem to be some problem.
I am getting the following error
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.rating
Extracted source (around line #1):
1: <%= number_with_precision(picture.rating, 1) %>/5 Stars
2:
-
4: Currently <%= number_with_precision(picture.rating, 1) %>/5
Stars.what exactly this picture is associated with? Is this picture, in my
view corresponds to :picture following in rjs file?page.replace_html “star-ratings-blockâ€, :partial => ‘rating/rating’,
:locals => { :picture=> @picture }Code at controller looks like:
def rate
@picture = Picture.find(params[:id])
Rating.delete_all([“rateable_type = ‘Picture’ AND rateable_id = ? AND
user_id = ?”,
@picture.id, current_user.id])
@picture.add_rating Rating.new(:rating => params[:rating],
:user_id => current_user.id)
end
endAny help would be appreciated. thanks.
3: