ruby on rails - paperclip process file contents before upload -
i want compute hash before uploading file no duplicates stored on server.
using paperclip gem, what's best approach processing on file before saving or inserting data in database?
activemodel has callback before_create
(among others) make ideal place compute before record created. full list of callbacks available, see ruby on rails guides: active record validations , callbacks.
class asset has_attached_file :image before_create :do_something def do_something end end
Comments
Post a Comment