Files
nairobi/config/initializers/vote_extensions.rb
Javi Martín e8195c201d Avoid warnings during initialization
These warnings appear in the logs in the development environment, and,
with Rails 7, the application will crash. When running the tests, they
would appear in the standard error ouput if we set `config.cache_classes
= false` in the test environment but, since that isn't the case, they
don't.

To reproduce these warnings (or the lack of them), start a Rails console
in development and check the log/development.log file.
2024-04-11 19:08:02 +02:00

23 lines
517 B
Ruby

Rails.application.reloader.to_prepare do
ActsAsVotable::Vote.class_eval do
include Graphqlable
end
end
ActsAsVotable::Vote.class_eval do
belongs_to :signature
belongs_to :budget_investment, foreign_key: "votable_id", class_name: "Budget::Investment"
scope :public_for_api, -> do
where(votable: [Debate.public_for_api, Proposal.public_for_api, Comment.public_for_api])
end
def self.count_for(votable_type)
where(votable_type: votable_type).count
end
def value
vote_flag
end
end