]> git.openstreetmap.org Git - rails.git/commitdiff
Proper way to get path to small avatar
authorHerve Saint-Amand <git@saintamh.org>
Mon, 2 Jan 2017 21:35:59 +0000 (21:35 +0000)
committerHerve Saint-Amand <git@saintamh.org>
Mon, 2 Jan 2017 21:35:59 +0000 (21:35 +0000)
Rather than performing perilous string substitution on paths, just use the built-in way to select the small version of the avatar image file.

app/models/notifier.rb

index 873cfafc41bc5fc89bb7d00b681016fd0e514871..40a516a927a388d81d91b0bd8a0012a6102e2def 100644 (file)
@@ -182,7 +182,7 @@ class Notifier < ActionMailer::Base
   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