# Acts\_as\_rateable in Beast

**URL:** <https://www.ruby-forum.com/t/acts-as-rateable-in-beast/105882>\
**Category:** Rails\
**Created:** [June 4, 2007, 9:30am UTC](https://www.ruby-forum.com/t/acts-as-rateable-in-beast/105882 "2007-06-04T09:30:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![monjurul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@monjurul](https://www.ruby-forum.com/u/monjurul)\
**Post date:** [June 4, 2007, 9:30am UTC](https://www.ruby-forum.com/t/acts-as-rateable-in-beast/105882/1 "2007-06-04T09:30:37Z")

</div>

I’m trying to implement acts\_as\_rateable to my Beast installation to  
give users the option to rate posts (like reddit). I chose  
acts\_as\_rateable as it supposedly easily allows reddit-type voting but  
I’m having some problems setting it up and the documentation seems  
outdated.  
([Acts As Rateable Plugin | Juixe Techknow](http://www.juixe.com/techknow/index.php/2006/07/05/acts-as-rateable-plugin/))

So far, I’ve added acts\_as\_rateable to my posts model and I’ve added  
this method to my controller:

def vote\_up  
return unless logged\_in?  
rateable = @rateable\_class.find(params[:id])  
# Delete the old ratings for current user  
Rating.delete\_all([“rateable\_type = ? AND rateable\_id = ? AND  
user\_id = ?”, @rateable\_class.base\_class.to\_s, params[:id],  
@current\_user.id])  
rateable.add\_rating Rating.new(:rating =\> 1, :user\_id =\>  
@current\_user.id)  
end

Is there a way to dynamically update (ajax) the rating in my view  
without having to refresh the page? I’ve tried link\_to\_remote and am  
loading javascript files but it does not seem to be working, my partial  
looks like this:

 \<%= number\_with\_precision(asset.rating, 1) %\> (\<%= asset.ratings.size %\> votes) | \<%= link\_to\_remote("voteup", {:url =\> { :controller =\> "posts", :action =\> "voteup", :id =\> asset.id, :rating =\> 1, :rateable\_type =\> asset.class.to\_s} } ) %\>

Thanks ahead for the help!

---

<div class="post-metadata">

**Author:** ![monjurul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@monjurul](https://www.ruby-forum.com/u/monjurul)\
**Post date:** [June 4, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/acts-as-rateable-in-beast/105882/2 "2007-06-04T17:21:56Z")

</div>

I ran into the same problem when i was trying to implement the  
acts\_as\_rateable too. It seemed like my application wasn’t picking up  
the .rjs template at all (where it called  
page.replace\_html “star-ratings-block”, :partial =\> ‘rating/  
rating’, :locals =\> { :product =\> @product }

so instead I found that you can put that call in the RatingController:

def rate

( …other code …)

render :update do |page|

```
    page.replace_html 'star-ratings-block' , :partial => "rating/

```

rating", :locals =\> { :product =\> @prod}

end

end

See if that works for you…and I’m curious if anyone has any  
suggestions as to why the .rjs template might not be working.

On Jun 4, 2:30 am, Monjurul D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
