Skip to content

Commit

Permalink
Avoid warnings during initialization
Browse files Browse the repository at this point in the history
These warnings appear in the logs in the development environment. 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.
  • Loading branch information
javierm committed Apr 10, 2024
1 parent 62ff478 commit 75ded42
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
8 changes: 6 additions & 2 deletions config/initializers/acts_as_taggable_on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
# config.base_class = "ApplicationRecord"
end

Rails.application.reloader.to_prepare do
ActsAsTaggableOn::Tag.class_eval do
include Graphqlable
end
end

module ActsAsTaggableOn
Tagging.class_eval do
after_create :increment_tag_custom_counter
Expand Down Expand Up @@ -39,8 +45,6 @@ def category?
kind == "category"
end

include Graphqlable

scope :public_for_api, -> do
where(
kind: [nil, "category"],
Expand Down
16 changes: 9 additions & 7 deletions config/initializers/disable_active_storage_uploads.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
ActiveStorage::DirectUploadsController.class_eval do
def create
head :unauthorized
Rails.application.reloader.to_prepare do
ActiveStorage::DirectUploadsController.class_eval do
def create
head :unauthorized
end
end
end

ActiveStorage::DiskController.class_eval do
def update
head :unauthorized
ActiveStorage::DiskController.class_eval do
def update
head :unauthorized
end
end
end
10 changes: 6 additions & 4 deletions config/initializers/globalize.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Rails.application.reloader.to_prepare do
Globalize::ActiveRecord::Translation.class_eval do
include SkipValidation
end
end

module Globalize
module ActiveRecord
module InstanceMethods
Expand All @@ -9,10 +15,6 @@ def save(...)
end
end
end

class Translation
include SkipValidation
end
end
end

Expand Down
8 changes: 6 additions & 2 deletions config/initializers/vote_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
ActsAsVotable::Vote.class_eval do
include Graphqlable
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"

Expand Down

0 comments on commit 75ded42

Please sign in to comment.