Sha256: e35befb0081e865c99e079fa33fbe1dd87bd857e47f731dd99a33bbee10b2468
Contents?: true
Size: 761 Bytes
Versions: 1
Compression:
Stored size: 761 Bytes
Contents
require 'tori' module Tori module ActiveRecord include Define # Filename hash usgin `id` attribute by default. # And you can change this attribute, But it's should be record unique. # # @example: # class Photo < ActiveRecord::Base # tori :image, id: :id # end def tori(name) super name_hash_get = "#{name}_hash".to_sym after_save do uploader = __send__ name filename = __send__ name_hash_get Tori.config.backend.copy(uploader.path, filename) if uploader && filename end after_destroy do filename = __send__ name_hash_get Tori.config.backend.delete(filename) if filename end end end end ::ActiveRecord::Base.extend(Tori::ActiveRecord)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tori-0.0.2 | lib/tori/rails.rb |