Fix error when rendering public pages with media attachments
This commit is contained in:
parent
e521eae200
commit
349b708872
|
@ -27,7 +27,14 @@ class MediaController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_media_attachment
|
def set_media_attachment
|
||||||
@media_attachment = MediaAttachment.attached.find_by!(shortcode: params[:id] || params[:medium_id])
|
id = params[:id] || params[:medium_id]
|
||||||
|
if id.nil?
|
||||||
|
return
|
||||||
|
elsif id.size == 19 # SecureRandom.url_safe(14)
|
||||||
|
@media_attachment = MediaAttachment.local.attached.find_by!(shortcode: id)
|
||||||
|
else
|
||||||
|
@media_attachment = MediaAttachment.local.attached.find_by!(id: id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_permitted_status!
|
def verify_permitted_status!
|
||||||
|
|
|
@ -218,7 +218,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
shortcode
|
shortcode.presence || id&.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def focus=(point)
|
def focus=(point)
|
||||||
|
|
Reference in New Issue