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.
This commit is contained in:
Javi Martín
2024-03-29 00:42:48 +01:00
parent 59f84deca1
commit e8195c201d
4 changed files with 27 additions and 15 deletions

View File

@@ -7,6 +7,12 @@ ActsAsTaggableOn.setup do |config|
# config.base_class = "ApplicationRecord" # config.base_class = "ApplicationRecord"
end end
Rails.application.reloader.to_prepare do
ActsAsTaggableOn::Tag.class_eval do
include Graphqlable
end
end
module ActsAsTaggableOn module ActsAsTaggableOn
Tagging.class_eval do Tagging.class_eval do
after_create :increment_tag_custom_counter after_create :increment_tag_custom_counter
@@ -39,8 +45,6 @@ module ActsAsTaggableOn
kind == "category" kind == "category"
end end
include Graphqlable
scope :public_for_api, -> do scope :public_for_api, -> do
where( where(
kind: [nil, "category"], kind: [nil, "category"],

View File

@@ -1,11 +1,13 @@
ActiveStorage::DirectUploadsController.class_eval do Rails.application.reloader.to_prepare do
ActiveStorage::DirectUploadsController.class_eval do
def create def create
head :unauthorized head :unauthorized
end end
end end
ActiveStorage::DiskController.class_eval do ActiveStorage::DiskController.class_eval do
def update def update
head :unauthorized head :unauthorized
end end
end
end end

View File

@@ -1,3 +1,9 @@
Rails.application.reloader.to_prepare do
Globalize::ActiveRecord::Translation.class_eval do
include SkipValidation
end
end
module Globalize module Globalize
module ActiveRecord module ActiveRecord
module InstanceMethods module InstanceMethods
@@ -9,10 +15,6 @@ module Globalize
end end
end end
end end
class Translation
include SkipValidation
end
end end
end end

View File

@@ -1,6 +1,10 @@
ActsAsVotable::Vote.class_eval do Rails.application.reloader.to_prepare do
ActsAsVotable::Vote.class_eval do
include Graphqlable include Graphqlable
end
end
ActsAsVotable::Vote.class_eval do
belongs_to :signature belongs_to :signature
belongs_to :budget_investment, foreign_key: "votable_id", class_name: "Budget::Investment" belongs_to :budget_investment, foreign_key: "votable_id", class_name: "Budget::Investment"