Hello, I am having some trouble 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 i fail at working it. i am getting this 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(asset.rating, 1) %>/5 Stars<br> 2: <ul class=''star-rating''> 3: <li class=''current-rating'' style=''width:<%= (asset.rating * 30).to_i -%>px;''> 4: Currently <%= number_with_precision(asset.rating, 1) %>/5 Stars. .... the model i am trying to use rateable with is my address model (my addresses table that contains name, zipcode, etc...) if my view is this: <% for column in Address.content_columns %> <p> <%= column.human_name %>:</b> <%=h @address.send(column.name) %> </p> <% end %> where do i add this? <div id="star-ratings-block"> <%= render :partial => "rating/rating", :locals => { :asset => @asset } %> </div> how does the rating system know to keep values for my address? dont i need to make some sort of relationship? thanks for any help!!!!!! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Dear Koloa: I went through the walkthrough you linked to, and got past the issue you encountered.... The error you are seeing has to do with the the fact that the partial is referring to asset. You probably want to change that to something else (as well as in the RJS code and the controller). You also want to be careful with the line: Rating.delete_all(["rateable_type = ''Posting'' AND rateable_id = ? AND user_id = ?", @posting.id, current_user_id.to_s]) current_user_id is a string in the migration described If you (or anyone else) wants to see the code I came up with, please email me.... I wrote a very simple app that lets you create postings using scaffolding, and vote on them... The only thing that I''m not happy with is that after voting, the post name disappears! (and I am pretty sure that has to do with the fact that the rate controller needs to do something else that I''m not doing, but I''m not 100% sure.... [''dominique'', ''plante@gmail'', ''com''].join(''.'') Thanks! Dominique koloa wrote:> Hello, > I am having some trouble 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 i fail at working it. > > i am getting this 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(asset.rating, 1) %>/5 Stars<br> > 2: <ul class=''star-rating''> > 3: <li class=''current-rating'' style=''width:<%= (asset.rating * > 30).to_i -%>px;''> > 4: Currently <%= number_with_precision(asset.rating, 1) %>/5 > Stars. > .... > > > the model i am trying to use rateable with is my address model (my > addresses table that contains name, zipcode, etc...) > > if my view is this: > > <% for column in Address.content_columns %> > <p> > <%= column.human_name %>:</b> <%=h @address.send(column.name) %> > </p> > <% end %> > > where do i add this? > <div id="star-ratings-block"> > <%= render :partial => "rating/rating", :locals => { :asset => @asset } > %> > </div> > > > how does the rating system know to keep values for my address? dont i > need to make some sort of relationship? > > > > thanks for any help!!!!!!-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hello Dominique, Thanks for the reply. I seemed of gotten passed that problem but now i have a new one! when i click on the stars, no action seems to take place. i put printout statements to see if there is any action but nothing. is asset the model that is acting as rateable? if my model is address, do i set asset => @address in my view? also, do i move the rate function in the ratingController to my personal controller? 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
im almost there. it seems everything is fine but how do i make it so after the user rates, it takes away there ability to change the rating? i want to display something like, :sorry you rated already etc..." but what i did is changed current_user.id to the params[:id] (which is my address ID) is this correct? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
use the rated_by_user method @rate.rated_by_user?(@session[:user]) and user? On 9/24/06, koloa <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > im almost there. > > it seems everything is fine but how do i make it so after the user > rates, it takes away there ability to change the rating? i want to > display something like, :sorry you rated already etc..." > > > but what i did is changed current_user.id to the params[:id] (which is > my address ID) > > is this correct? > > -- > Posted via http://www.ruby-forum.com/. > > > >-- www.blogsaic.com search, post, blog --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
It looks like your steaming along again!!!! Post again if you feel any of your questions have not been answered :) Thanks! Dominique koloa wrote:> im almost there. > > it seems everything is fine but how do i make it so after the user > rates, it takes away there ability to change the rating? i want to > display something like, :sorry you rated already etc..." > > > but what i did is changed current_user.id to the params[:id] (which is > my address ID) > > is this correct?-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
hello, how do i use this? do all sessions have user or do i have to define it in a session model? do i put this code in the rate function and if its true, return and do nothing? else, record the rating? thanks Dominique i still have a few questions about the plugin.. what is rateable_id and user_id in the rateable table? in my rate function, rateable_type = my model name, rateable_id = my model id, and user_id = also my model id. //my model == Address table. is this right? Dion Hewson wrote:> use the rated_by_user method > > @rate.rated_by_user?(@session[:user]) and user? > > > > On 9/24/06, koloa <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> my address ID) >> >> is this correct? >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > > www.blogsaic.com > search, post, blog-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
rateable_id is the id of the table you are rating so for you, rateable_id will be equal to address_id user_id should be the id of the user who posts the rate, this is used to ensure that a user only rates something once. there is an example of my rating system at www.blogsaic.com it works pretty much like the rating system at youtube login and rate some tiles if you want a similar system, I can give you all the bits of code you need On 9/24/06, koloa <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > hello, > > how do i use this? do all sessions have user or do i have to define it > in a session model? > > do i put this code in the rate function and if its true, return and do > nothing? else, record the rating? > > > thanks Dominique > i still have a few questions about the plugin.. > > what is rateable_id and user_id in the rateable table? in my rate > function, rateable_type = my model name, rateable_id = my model id, and > user_id = also my model id. > > //my model == Address table. > > > is this right? > > > > > Dion Hewson wrote: > > use the rated_by_user method > > > > @rate.rated_by_user?(@session[:user]) and user? > > > > > > > > On 9/24/06, koloa <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> my address ID) > >> > >> is this correct? > >> > >> -- > >> Posted via http://www.ruby-forum.com/. > >> > >> > > >> > > > > > > -- > > > > www.blogsaic.com > > search, post, blog > > > -- > Posted via http://www.ruby-forum.com/. > > > >-- www.blogsaic.com search, post, blog --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
hello dion, your help would be greatly appeciated if you can share your code. my email is rubytree at-verizon-dot-net THANKS! Dion Hewson wrote:> rateable_id is the id of the table you are rating > > so for you, rateable_id will be equal to address_id > > user_id should be the id of the user who posts the rate, this is used to > ensure that a user only rates something once. > > > there is an example of my rating system at www.blogsaic.com > > it works pretty much like the rating system at youtube > > login and rate some tiles > > if you want a similar system, I can give you all the bits of code you > need > > > > On 9/24/06, koloa <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> is this right? >> > >> > >> > >> > > > -- > > www.blogsaic.com > search, post, blog-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---