Use relative URLs for avatars and rich text attachments
These URLs can be problematic or inconsistent, as we might end up with rich text content with beta URLs for attachments being used in production, or viceversa. It'll also be problematic when importing or exporting data between a self-hosted instance and the SaaS version.
This commit is contained in:
@@ -42,6 +42,6 @@ module AvatarsHelper
|
||||
end
|
||||
|
||||
def avatar_image_tag(user, **options)
|
||||
image_tag user_avatar_url(user, script_name: user.account.slug), aria: { hidden: "true" }, size: 48, title: user.name, **options
|
||||
image_tag user_avatar_path(user, script_name: user.account.slug), aria: { hidden: "true" }, size: 48, title: user.name, **options
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,17 @@ ActiveSupport.on_load(:active_storage_blob) do
|
||||
end
|
||||
end
|
||||
|
||||
ActiveSupport.on_load(:action_text_content) do
|
||||
# Install our extensions after ActionText::Engine's
|
||||
ActiveSupport.on_load(:active_storage_blob) do
|
||||
# Ensure all <action-text-attachment>s have a "url" attribute that's a relative
|
||||
# path (for portability across host name changes, beta environments, etc).
|
||||
def to_rich_text_attributes(*)
|
||||
super.merge url: Rails.application.routes.url_helpers.polymorphic_url(self, only_path: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Don't configure replica connections for ActiveStorage::Record.
|
||||
# When ActiveStorage uses `connects_to`, it creates a separate connection pool
|
||||
# from ApplicationRecord. This causes after_commit callbacks to fire in
|
||||
|
||||
Reference in New Issue
Block a user