ウェブサービスを作っています。

Paperclip で保存先を動的に指定する

path とか url に proc を渡す。第1引数に Attachment オブジェクトが入ってきます。

has_attached_file(:header_image,
  :path => proc { |attachment|
    ":rails_root/public/images/games/#{ attachment.instance.code }/header_image.:extension"
  },
  :url => proc { |attachment|
    "/images/games/#{ attachment.instance.code }/header_image.:extension"
  })

attachment.instance でモデルのオブジェクトがとれます。