Monday, May 5, 2008

Starbox for rating in Ruby on Rails

So graphically I chose the starbox library ( Starbox Link ). Nick Stakenburg I think has done a good job. I am not an expert in js by any means, but its small, and pretty customizable. Also this library is built using prototype and scriptaculous (effects.js), so for rails these are already included. If anyone knows why this isn't a good library please leave a comment. Anyways.. so integration.

* I just realized with latest starbox he has changed the license. Currently I am using an older version with a MIT license. I have created hosting for this project here open-starbox project. Please update with any changes you make to integrate with latest prototype or scriptaculous, if you plan on using.



  • Paths : overlayImages path. When using a nested route , such as /path/id/path/id. I believe this library reads as a relative path .. so passing in "../images/starbox/" .. it tries to retrieve image from path /path/id/images/starbox , and obviously this is not the correct path. This took awhile to figure out. So for now I'm just hard coding the path in the starbox.js file. Besides for this project the path will be static anyways and won't be changing.
  • Parameters : I've had to continue to modify the open starbox library and add to attributes to be passed, the ratedId, and raterId. My use case is where the logged in user, can rate multiple users, but one or multiple, when using the Ajax.request the two id's are needed for the acts_as_rated.   
  • Ajax.request & rails security : this could be a whole blog posting by itself , and I may have to revisit sometime. But when implementing code
    Ajax.request('url_for(path_to_url())')
    within the controller it throws this Exception - ActionController::InvalidAuthenticityToken ??? This security answer link is an answer, but I still don't think this is the best way to do it. Prototype is not passing security token. Update : seems to resolved itself.. very odd.

Note: 05/07/08 the integration of starbox js lib, is correct. acts_as_rated, although is good, can not use to rate User model refer to ruby forge. Look for later post on integration

No comments: