Star Rating Component?


#1

Hi,

I’m looking for a star rating component for RoR, a bit like Votio
(http://redalt.com/downloads/ - find the votio heading) or the star
rating used on Amazon.

I don’t really need the AJAX capabilities, just the ability to bind the
results to a hidden drop down, or radio inputs.

Multiple raters per page is also an issue.

Any recomendations?


#2

On 07 Mar 2006, at 14:42, Martin Smith wrote:

Multiple raters per page is also an issue.

Any recommendations?

If you have the Rails Recipes book, you could read up on the
JavaScript helper section and implement the open source version from
the Yahoo UI Library and hide it behind one simple ruby command.

Best regards

Peter De Berdt


#3

Hi Martin,

I’ve got a flash-version I built and included via flash-javascript
integration kit. Works great. Let me know if you want it and I’ll send
it
over.

Steve


#4

Peter De Berdt wrote:

If you have the Rails Recipes book, you could read up on the
JavaScript helper section and implement the open source version from
the Yahoo UI Library and hide it behind one simple ruby command.

Sadly I don’t. I have looked at the Yahoo UI Library, but could only
find the Star Rater in the patterns section, not in the download.

Martin


#5

Steve O. wrote:

Hi Martin,

I’ve got a flash-version I built and included via flash-javascript
integration kit. Works great. Let me know if you want it and I’ll send
it
over.

Steve

Thanks, for that. I would really prefer to keep it just javascript
though. I assume that for your version you need flash installed.


#6

On 07 Mar 2006, at 16:03, Martin Smith wrote:

Peter De Berdt wrote:

If you have the Rails Recipes book, you could read up on the
JavaScript helper section and implement the open source version from
the Yahoo UI Library and hide it behind one simple ruby command.

Sadly I don’t. I have looked at the Yahoo UI Library, but could only
find the Star Rater in the patterns section, not in the download.

Well, the nice thing about javascript is that you can extract it from
a page:

http://us.js2.yimg.com/us.yimg.com/lib/ls/js/
yg_multirate_200602281800.js

They then use the following code to show the rating system:

Just go to http://local.yahoo.com/, search for “Restaurants” in
Location “New York”, click on a restaurant for the detail (which has
the widget) and then look at the source.

Best regards

Peter De Berdt


#7

Dylan, Can we see the controller code you are using?

John


#8

I think the CSS approach to this is the best. I implemented the
following
approach, which is very popular:
http://komodomedia.com/blog/index.php/2006/01/09/css-star-rating-part-deux/

The code I used below enabled the “ajaxy” part of this… so when you
click
on a star, it automatically saves your pick… much like the Netflix
star
system.

===========================

    <% if @review %>
  •  
  • <% end %>
        <% for i in 1..5 %>
        <li>
            <%= link_to_remote i, {:update => 'super',
                                   :url   => {:action    =>

‘rate_cause’,
:cause_id =>
@cause.id,
:user_id =>
@user.id,
:rating => i}},
{:class =>
num2english(i)+"-stars"}
%>

<% end %>

It works beautifully !
Let me know if you have any questions.


#9

Sure ! Here you go… but please excuse the mess :slight_smile:

controller

def rate_cause
id, id, rating = params[:id], params[:id], params[:rating]
@review = Review.find(:first, :conditions => [“id = ? and id = ?”, id,
id])
if @review
@review.update_attribute(“rating”, rating)
else
@review = Review.create(:id => id, :id => id, :rating => rating)
end
render(:layout => false)
end

rate_cause.rhtml

<% if @review %>

  •  

  • <% end %>

    #10

    Dylan,

    what does your Review table look like?(database schema)

    John


    #11

    hi
    can uany one give me the entire coding for starrating.
    plz…
    thanks