Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class User < ActiveRecord::Base
has_many :notifications

has_attached_file :image, styles: { :thumb => "150x150#", :medium => "250x250#" },
path: ":attachment/:style/:basename.:extension"
path: ":attachment/:style/:basename_:updated_at.:extension",
validate_media_type: false # TODO comment out for prod
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/

default_scope { order(created_at: :desc) }
Expand Down
9 changes: 9 additions & 0 deletions script/migrate_user_attachments_to_new_path.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class FakeUser < User
has_attached_file :image, styles: { :thumb => "150x150#", :medium => "250x250#" },
path: ":attachment/:style/:basename.:extension"
end

FakeUser.find_each do |fake_user|
User.find(fake_user.id).update(image: fake_user.image)
# fake_user.image.destroy
end