class UserProfile < ActiveRecord::Base
  image_accessor :picture do
    storage_path :generate_picture_path
  end

  belongs_to :user

  protected

  def generate_picture_path
    hash = Digest::SHA1.file(picture.path).hexdigest
    "attachments/user_profile/#{hash[0..6]}/#{hash}"
  end
end

class UserProfile < ActiveRecord::Base
  image_accessor :picture do
    storage_path :generate_picture_path
  end

  belongs_to :user

  protected

  def generate_picture_path
    hash = Digest::SHA1.file(picture.path).hexdigest
    "profile_pictures/#{hash[0..2]}/#{hash[3..5]}/#{hash}"
  end
end

Reduce profile picture path size and make safe.
Reduce profile picture path size and make safe.

* 16^3 directory entries is well within FS limits.
* DragonFly root path means "attachments" is not needed.
* Give path a more relevant name.
