Avoid double render in Avatars#show
After sending the conditional 304 response, we were still attempting to render the response, which is unnecessary.
This commit is contained in:
@@ -4,12 +4,8 @@ class Users::AvatarsController < ApplicationController
|
||||
before_action :set_user
|
||||
|
||||
def show
|
||||
fresh_when @user, cache_control: { max_age: 30.minutes, stale_while_revalidate: 1.week }
|
||||
|
||||
if @user.avatar.attached?
|
||||
send_blob_stream @user.avatar
|
||||
else
|
||||
render_initials
|
||||
if stale? @user, cache_control: { max_age: 30.minutes, stale_while_revalidate: 1.week }
|
||||
render_avatar_or_initials
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,6 +19,14 @@ class Users::AvatarsController < ApplicationController
|
||||
@user = Current.account.users.find(params[:user_id])
|
||||
end
|
||||
|
||||
def render_avatar_or_initials
|
||||
if @user.avatar.attached?
|
||||
send_blob_stream @user.avatar
|
||||
else
|
||||
render_initials
|
||||
end
|
||||
end
|
||||
|
||||
def render_initials
|
||||
render formats: :svg
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user