简体   繁体   中英

In rails, how to save uploaded files (image or pdf) through paperclip to database?

As I am newbie to the rails, I am not sure how to save the files (pdf/image) to the database in the rails. I am able to upload the image and save it locally and the image info gets save in the database..but I want to save the whole file or image in the database. Your suggestion will be greatly appreciated!

Thanks!

Source: https://github.com/softace/paperclip_database

gem "paperclip_database", "~> 2.0"

class User < ActiveRecord::Base
  has_attached_file :avatar,
                    :storage => :database ## This is the essence
                    :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM