So I'm implementing an up/down voting mechanism for which I'm generating a model. So far I understand that a video (what will be voted on) has one vote_count, and vote_count belongs to videos. However, I also want to track in my vote_count database the user that has voted on the video. Does that mean that a vote_count has many users, and that a user belongs to a vote_count?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Eager-loading association count with Arel (Rails 3
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
相关文章
- laravel create model from custom stub when using p
- Ruby using wrong version of openssl
- Right way to deploy Rails + Puma + Postgres app to
- AWS S3 in rails - how to set the s3_signature_vers
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- “No explicit conversion of Symbol into String” for
Am I missing something here? Why not assign a
netVoteTally
as a property ofVideos
. Initialize it to zero whenvideo.new
is called and haveincNetVideoTally
anddecNetVideoTally
methods that are accessible outside the video method? Just my $0.02.It may be easier to track the votes as independent records, such as this:
If you have people voting up and down, you will need to track the net vote total somehow. This can be tricky, so you may want to look for a voting plugin.