musreg
musreg

Reputation: 33

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!

Upvotes: 0

Views: 542

Answers (1)

Tom Fast
Tom Fast

Reputation: 1158

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

Upvotes: 1

Related Questions