diogob / carrierwave-postgresql

Use PostgreSQL large objects (AKA BLOBs) to store your files inside the database
http://diogob.github.com/carrierwave-postgresql/
MIT License
56 stars 25 forks source link

OID getting persisted but not image file. #20

Closed timigod closed 9 years ago

timigod commented 9 years ago

(I'm a noob) I've set up as is stated in the readme.md. I've created my models and mounted my uploaders previously. Carrier wave was working fine when I was uploading to file system. All I needed to do was add an oid column to my model and configure the uploader for postgresql

storage :postgresql_lo

then I commented out

  # def store_dir
    # "images/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  # end

When I upload, the oid gets added to the table of my model but not the image itself. I read something about the images being stored in another table but there's no instruction on how to create this table or something.

diogob commented 9 years ago

The table is a system table. Take a look here for a better explanation of how the database large objects work: http://www.postgresql.org/docs/current/static/largeobjects.html If the oid is being stored in the table you should be able to retrieve it using the interface provided by the gem, just use the name of the attribute in your model instance and it should return a IO object..