I need to store some binary files (spreadsheets) and some web pages in my table in SQLite DB in Rails. I know that storing files in the 开发者_运维问答DB isn't a good practice but in this case, the convenience outweighs all else since I only need to store files rarely. Thank you.
You should use the BLOB
type for this purpose.
The binary
data type maps to to the BLOB
in SQLite. The size can be specified by using the limit
parameter. Here's an example from an self.up
method of a migration:
t.column :mystuff, :binary, :limit => 10.megabyte
精彩评论