开发者

Voting system to choose between two pictures

I am trying to create a voting picture system on rails 3. What I开发者_Python百科 would like to have happen is have two pictures, and have people on the site vote for which one they like more. I know they have a thumbs_up gem, which creates a voting system quickly. Is there a way to either modify the gem to have it work for pictures or is there a simple way to create this?


you don't need to modify the gem. Just create an appropriate Model for your Images:

class Image < ActiveRecord::Base
  acts_as_voteable
end

and for your users:

class User < ActiveRecord::Base
  acts_as_voter
end

after you can compare the upvote count of 2 images with something like:

image1.votes_for > image2.votes_for
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜