Remove monkey-patch of the Numeric class

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).
This commit is contained in:
Javi Martín
2024-03-17 22:40:11 +01:00
parent d19d341622
commit f8c97b9bb9
3 changed files with 1 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
module VotesHelper
def debate_percentage_of_likes(debate)
debate.likes.percent_of(debate.total_votes)
(debate.likes.to_f * 100 / debate.total_votes).to_i
end
def votes_percentage(vote, debate)

View File

@@ -1,5 +1,3 @@
require "numeric"
class Debate < ApplicationRecord
include Flaggable
include Taggable

View File

@@ -1,5 +0,0 @@
class Numeric
def percent_of(n)
(to_f / n * 100).to_i
end
end