Sha256: 5534534bb519aaf0e9568bb37539e37b1f50a765e7dfd61f643f64965afd1f9a
Contents?: true
Size: 637 Bytes
Versions: 3
Compression:
Stored size: 637 Bytes
Contents
require 'securerandom' module Notee class Image < ActiveRecord::Base # accessors attr_accessor :file # callbacks before_save :manage_image private def manage_image return unless self.file image_dir = Rails.root.to_s + "/public/notee" FileUtils.mkdir_p(image_dir) unless FileTest.exist?(image_dir) image_name = Time.now.strftime('%Y%m%d%H%M%S') + '--' + SecureRandom.uuid + '.jpg' self.transaction do open(image_dir + "/" + image_name, 'wb') do |output| output.write(self.file.read) end self.content = image_name end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
notee-0.3.1 | app/models/notee/image.rb |
notee-0.3.0 | app/models/notee/image.rb |
notee-0.2.9 | app/models/notee/image.rb |