This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We need to patch PaperTrail to deal with Campaign having a `serialize` field that also has an `attribute` definition with a `default` value set for the attribute, as well as a database-level `default` set as well. For whatever all the reasons, PaperTrail tries to serialize the database-default, which is already a string. This throws an `ActiveRecord::SerializationTypeMismatch` error, as it is expecting the valued being serialized to be an `Array`. In this case, we can solve our problem by simply catching this error and checking of the value is already serialized. | |
module PaperTrail | |
module AttributeSerializers | |
class CastAttributeSerializer | |
private | |
def serialize(attr, val) | |
AttributeSerializerFactory.for(@klass, attr).serialize(val) | |
rescue ActiveRecord::SerializationTypeMismatch => error | |
if val.is_a?(String) && YAML.load(val) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "activerecord", "~> 7.0.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/jobs/hubspot/webhooks/on_object_merged_job.rb | |
class Hubspot::Webhooks::OnObjectMergedJob < ApplicationJob | |
def perform(portal_id:, object_type:, merged_object_ids:, new_object_id:) | |
integration = Integration.find_by(source: :hubspot, uid: portal_id) | |
return unless integration.present? | |
integration | |
.organization | |
.integration_proxies | |
.where( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Application < Rails::Application | |
# Initialize configuration defaults for originally generated Rails version. | |
config.load_defaults 7.0 | |
# ensure that `update(files: [uploaded_file])` will append, not replace | |
config.active_storage.replace_on_assign_to_many = false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Returns a flat hash where all nested keys are flattened into an array of keys. | |
# | |
# hash = { key: 'value', nested: { key: 'nested_value' }, array: [0, 1, 2] } | |
# flatten_keys_of(hash) | |
# => { [:key]=>"value", [:nested, :key]=>"nested_value", [:array]=>[0, 1, 2] } | |
# | |
# Can also pass a Proc to change how nested keys are flattened: | |
# flatten_keys_of(hash, flattener: ->(*keys) { keys.join('.') }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JobRun < ActiveRecord::Base | |
FINISHED_RECOVERY_POINT = "FINISHED" | |
validates :job_class, presence: true | |
validates :job_id, presence: true | |
validates :serialized_job, presence: true | |
serialize :serialized_job, JSON | |
store :persisted_data | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DetailsPopoverComponent < ApplicationComponent | |
class InvalidSide < StandardError | |
def initialize(side) | |
super("`#{side}` must be one of `top`, `bottom`, `left`, or `right`") | |
end | |
end | |
class InvalidAlign < StandardError | |
def initialize(align) | |
super("`#{align}` must be one of `start`, `center`, or `end`") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module ArtifactInterface | |
extend ActiveSupport::Concern | |
extend Interfaceable | |
def key | |
raise NotImplementedError | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "httpx" | |
module Clientable | |
extend ActiveSupport::Concern | |
def initialize | |
@httpx = HTTPX | |
.plugin(:retries, retry_change_requests: true) | |
.max_retries(3) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
# Activate the gem you are reporting the issue against. |