Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix avatar defaults. Carrierwave uploader#default_url does not play well

with a default column value in the db.
  • Loading branch information...
commit 5a8f8dd456983875c6ada7a386b2218681c5fb33 1 parent 4fbc245
@pbm authored
View
8 app/uploaders/avatar_uploader.rb
@@ -11,10 +11,12 @@ def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
- # Provide a default URL as a default if there hasn't been a file uploaded:
+ # Provide a default URL as a default if there hasn't been a file
+ # uploaded. Note: do NOT set a default in the db for the avatar column.
+ # It will not play well with this method.
def default_url
- # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
- "/images/default_person.png"
+ # The version_name is something like "thumb" or "" (for default size).
+ "/images/" + [version_name, "default_person.png" ].compact.join('_')
end
# Process files as they are uploaded:
View
2  db/migrate/20110704193414_create_users.rb
@@ -5,7 +5,7 @@ def change
t.string :password_digest
t.string :first_name
t.string :last_name
- t.string :avatar, :default => '/images/default_person.png'
+ t.string :avatar
t.integer :membership_id
t.integer :hfc_number, :default => -1
t.boolean :is_public, :default => false
View
2  db/schema.rb
@@ -83,7 +83,7 @@
t.string "password_digest"
t.string "first_name"
t.string "last_name"
- t.string "avatar", :default => "/images/default_person.png"
+ t.string "avatar"
t.integer "membership_id"
t.integer "hfc_number", :default => -1
t.boolean "is_public", :default => false
View
BIN  public/images/thumb_default_person.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.