【发布时间】:2017-12-01 13:19:31
【问题描述】:
您好,我无法在我的网页上加载用户的图片。
cloudinary display error on web page
当我查看我的 Cloudinary 帐户时,我找不到图片。
res.cloudinary.com/di7e0fdiq/image/upload/v1498636677/rj2ijo3yb6yvmyrybnps.jpg
这是我的代码:我正在使用帮助程序来显示用户的图片。我在我的节目中称这个助手:
def user_picture_avatar(user, image_class)
if user.photo?
cl_image_tag(user.photo.path, class: image_class)
else
avatar_url = user.linkedin_picture_url || "http://placehold.it/100x100"
image_tag avatar_url, class: image_class
end
end
我直接在我的节目中测试了代码,也没有使用帮助程序,我得到了相同的结果。
<!-- avatar display using helper -->
<div class="user-show-photo">
<%= user_picture_avatar(current_user, "interview-show-avatar avatar-bordered-xl") %>
</div>
<!-- avatar display without helper -->
<div class="user-show-photo">
<%= cl_image_tag @user.photo.path, width: 400, height: 300, crop: :fill %>
</div>
当我查看网页上的检查器时,我得到以下信息:
我已经多次检查了我的 cloudinary、figaro、application.yml 和 strong params 设置,但似乎无法解决这个问题。
你能帮忙吗?
【问题讨论】:
-
你好,
user.photo.path的值是多少,根据文档,你为什么使用路径而不是图像名称cl_image_tag("sample.jpg", :width => 100, :height => 150, :crop => :fill)