This monkey-patch doesn't seem to be working with Zeitwerk, and we were only using it in one place, so the easiest way to solve the problem is to remove it. Note that, in the process, we're changing the operation so `* 100` appears before the division, so it's consistent with other places where we do similar things (like the `supports_percentage` method in the proposals helper).
16 lines
374 B
Ruby
16 lines
374 B
Ruby
module VotesHelper
|
|
def debate_percentage_of_likes(debate)
|
|
(debate.likes.to_f * 100 / debate.total_votes).to_i
|
|
end
|
|
|
|
def votes_percentage(vote, debate)
|
|
return "0%" if debate.total_votes == 0
|
|
|
|
if vote == "likes"
|
|
"#{debate_percentage_of_likes(debate)}%"
|
|
elsif vote == "dislikes"
|
|
"#{100 - debate_percentage_of_likes(debate)}%"
|
|
end
|
|
end
|
|
end
|