Is there a voting plugin available for rails 3? -
acts_as_voteable , vote_fu don't work on rails 3. there 1 work?
they simple set up. here's 1 can start :
class object < activerecord::base has_many :votes, :as => :votable has_many :voting_users, :through => :votes, :source => :user #object_controller def vote_up get_vote @vote.value += 1 unless @vote.value == 1 @vote.save respond_to |format| format.html {render :action => 'view'} format.js { render :action => 'vote'} end end private def get_vote current_object = objects.detect{|r| r.id == params[:id].to_i} @object = current_object @vote = current_object.votes.find_by_user_id(current_user.id) unless @vote @vote = vote.create(:user_id => current_user.id, :value => 0) current_object.votes << @vote end end
Comments
Post a Comment