Ich habe eine Rails4 App, die carrierwave
mit S3
und cloudfront
verwendet. Ich habe nur Probleme mit dem Fallback-Image. Wenn ich html
Antwort (<%= image_tag user.profile.avatar.url(:base_thumb), class: "profile-index-avatar" %>
) mit dem Helfer alles funktioniert, funktioniert gut, aber kann es nicht herausfinden, wie es mit json
Antwort funktioniert.Schienen Carrierwave + S3 + JSON Antwort
Wenn ich die HTML-Check-out (von json gebaut) in der Produktion auf der Root-Seite ist der Code:
1. jbuilder: <img src="https://example.com/small_thumb_default.png">
2st jbuilder: <img src="https://example.com/assets/small_thumb_default.png">
Nichts davon arbeiten .
Am Anfang dieser, wenn ich gehen lassen auf der Seite Benutzer sagen dann versucht es wie pic zu bekommen:
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">
.
Was soll ich ändern?
jbuilder erste Version
json.array! @other_notifications do |notification|
..
json.profile_image_url notification.sender.profile.avatar.url(:small_thumb)
...
end
jbuilder 2. Version
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
Uploader
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