title: Easiest way to store images in database on Heroku?
body: <p>We have a RoR 3.2 site on Heroku using their production tier PostgreSQL database. </p>
  
  <p>Our site users occasionally upload images of 0.5 - 2MB in size. For different reasons we want to store those images in the database, rather than as files on S3 or similar.</p>
  
  <p>If our site was image heavy, i.e. a Facebook clone, surely storing images in the db would not be a good thing.</p>
  
  <p>Anyway, it is not, so here are some of the reasons for wanting to store a users images in the database:</p>
  
  <ul>
  <li>Control over everything: S3 downtime and third party gems cannot break image handling/access to images.</li>
  <li>Easy delete: If a user cancels his account, we can easily delete all associated images with that account through our rails models (relation dependencies).</li>
  <li>Easier user data export: When a user wants to leave our site and take his data with him, we can more easily export his images rather than having to export from S3 </li>
  <li>Cost: Not a weighty argument, but since we're already paying for the database it will be cheaper than using S3 which costs (a small amount of) money.</li>
  <li>Backups: Not a weighty argument, but a backup of our db would include everything associated with our site (except the RoR code, of course).</li>
  </ul>
  
  <p>What is the easiest way to store images in the Heroku PostgreSQL database? Example code or link to a walk-through would be most welcome. </p>
  
  <p>Thanks :)</p>