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 Dolon
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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.
> (http://www.juixe.com/techknow/index.php/2006/07/05/acts-as-rateable-p...)
>
> 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:
>
> <div id="<%= asset.id %>">
> <%= 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} } ) %>
> </div>
>
> Thanks ahead for the help!
>
> --
> Posted viahttp://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?hl=en
-~----------~----~----~----~------~----~------~--~---