S3
ve cloudfront
ile carrierwave
kullanarak bir rails4 uygulaması var. Geri dönüş görüntüsüyle ilgili sorunum var. html
cevabını (<%= image_tag user.profile.avatar.url(:base_thumb), class: "profile-index-avatar" %>
) yardımı ile kullanırken, her şey iyi çalışıyor ancak json
yanıtıyla nasıl çalışacağını anlayamıyor. Ben kök sayfasındaki üretiminde (json inşa) html kontrol ederseraylar carrierwave + S3 + json yanıtı
kodudur:
1 jbuilder: <img src="https://example.com/small_thumb_default.png">
2st jbuilder: Bunlardan
Yok <img src="https://example.com/assets/small_thumb_default.png">
çalışıyoruz . Bunun üzerine
1 jbuilder: <img src="https://example.com/users/small_thumb_default.png">
2 jbuilder: <img src="https://example.com/users/assets/small_thumb_default.png">
.
Neyi değiştirmeliyim?
jbuilder 1 sürüm
json.array! @other_notifications do |notification|
..
json.profile_image_url notification.sender.profile.avatar.url(:small_thumb)
...
end
jbuilder 2 versiyon
json.array! @other_notifications do |notification|
..
if notification.sender.profile.avatar_url == "default.png"
json.profile_image_url "assets/small_thumb_default.png"
else
json.profile_image_url notification.sender.profile.avatar.url(:small_thumb)
end
...
end
yükleyici
process :resize_to_fit => [400, 400]
version :base_thumb do
process resize_to_fill: [85, 85]
end
version :small_thumb, :from_version => :base_thumb do
process :resize_to_fill => [40, 40]
end
def default_url
[version_name, "default.png"].compact.join('_')
end