ペーパークリップ補間を使用する必要があります。これは、ペーパークリップ3.5.2で機能します
class User < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: [ :slugged, :finders ]
Paperclip.interpolates :slug do |attachment, style|
attachment.instance.slug
end
has_attached_file :picture,
styles: { large: "512x512!", medium: "256x256!", thumb: "128x128!" },
default_url: "/images/:class/:style/missing.png",
hash_secret: "xxxxxxxxxxxxxxxxxxxxxx",
url: "/system/:class/:attachment/:slug/:style/:hash.:extension",
path: ":rails_root/public/system/:class/:attachment/:slug/:style/:hash.:extension"
end
また、ハッシュ化されたファイル名を使用して、ファイル名の個人情報を隠す方法も示しています。URL からファイル名を取得するために Web サーバーで何らかのルーティングを設定しない限り、URL とパスは一致する必要があります。