You are here: Browse Railsplugins With Blob Columns
== this will generate methods for a custom module which will then be ‘included’ by the class. e.g.
class Artwork < ActiveRecord::Base
with_blob_columns :original, :thumbnail
end
1. methods ‘original=’ and ‘thumbnail=’ will be generated for a module called Artwork::WithBlobColumns
2. Artwork will include Artwork::WithBlobColumns hence all instances will have the 2 methods, e.g.
art = Artwork.new art.original = open(“file_big.jpg”)note: file uploaded by browser can be set the same way:
assuming <input name="artwork[original]" type="file" />
art.original = params:artwork
note: if an empty file or non-file is given, the attribute value won’t be altered this is to facilitate “Edit” forms where users usually leave the file field blank. To nullify the field, access it directly:
art[:original] = nil
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly