Rails acts_as_votable contest

29 Views Asked by At

i'm working on a contest rails 7 app and i'm using act_as_votable to vote on user projects, but i'm stuck in the fact that user have to vote in every contest phases and vote have to be reinitialized for every phases but i'm my app it's the same vote count that is showned; how can i solve this please?

I tried to use a has_many_through relationship but it wasn't success.

1

There are 1 best solutions below

0
Lee Drum On

I think you can split the models into Contest has many Phase and then use acts_as_voteable for model Phase instead of Contest

The models should be:

class Contest < ApplicationRecord
 has_many :phases
end

class Phase < ApplicationRecord
  belongs_to :contest

  acts_as_voteable
end