Rateable plugin problem

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:


    3:

  • 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
    end

    Any help would be appreciated. thanks.

<%= number_with_precision(picture.rating, 1) %>

picture should be @picture

Thorsten M. wrote:

<%= number_with_precision(picture.rating, 1) %>

picture should be @picture

I even thought the same thing and tried that one before posting here,
But no luck still :frowning: