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<br>
2: <ul class=''star-rating''>
3: <li class=''current-rating''
style=''width:<%= (picture.rating *
30).to_i -%>px;''>
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.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---