Rather than performing perilous string substitution on paths, just use the built-in way to select the small version of the avatar image file.
def user_avatar_file_path(user)
image = user.image
if image.file?
def user_avatar_file_path(user)
image = user.image
if image.file?
- return image.path.sub("/original/", "/small/")
+ return image.path(:small)
else
return Rails.root.join("app", "assets", "images", "users", "images", "small.png")
end
else
return Rails.root.join("app", "assets", "images", "users", "images", "small.png")
end