Rails 3 rateable model - How to create ajax rating?

前端 未结 2 1693
北恋
北恋 2020-12-17 06:46

How do I create some simple ajax rating like there is on this page http://watir.com/documentation/ ? Every visitor should be able to rate, I dont need to set permissions. I

2条回答
  •  佛祖请我去吃肉
    2020-12-17 07:37

    Looks like the Watir documentation rating system is set up through polldaddy.

    For this particular case, it appears they include the polldaddy javascript which populates the rating div container with their star rating widget. Looks like there's a corresponding javascript object which you can inspect:

    console.log( PDRTJS_101132_page_2.avg_rating ); //=> 4
    

    If you had numerous rating widgets like these on a page, and you were able to make a collection of the javascript objects paired with their divs, presumably you could sort them based on that average rating property.

提交回复
热议问题