Storing pdf files in a Rails application

How do I save a PDF file in my Rails application so that users can get / download them?

In my migration, would I use a data type t.binary?

Then in my controller / view, how do I present this data?

+3
source share
3 answers

The answer here probably depends. Depends on the size and number of PDF files in which users must be logged in to view them, etc.

If you have many large PDF files, you probably should not store them in the database - just save them in the file system and save the file location in the database model.

, - .

PDF , ( ) - PDF , - Rails.

+4

Paperclip, - , .

+3

This question is probably not specific to rails, but probably the best way to do this is to create a pdf file and save it in your file system, and then save the file name records and the date they were created in your database (before deleting the old ones, if you need).

+1
source

Source: https://habr.com/ru/post/1707037/


All Articles