Sha256: 5e5d8ccf3fcb36025caf47d27b8f3de4053408c1b17f1c33f7df65ce38167bd7
Contents?: true
Size: 512 Bytes
Versions: 2
Compression:
Stored size: 512 Bytes
Contents
class Redde::Photo < ActiveRecord::Base mount_uploader :src, PhotoUploader self.table_name = 'redde_photos' opts = { polymorphic: true } opts.merge!(optional: true) if Rails.version.split('.')[0..1].join.to_i >= 51 belongs_to :imageable, opts default_scope { order(:position) } before_save :set_token, unless: :persisted_link? def set_token self.token = SecureRandom.uuid unless token.present? end def persisted_link? imageable_type.present? && imageable_id.present? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
redde-0.4.4 | app/models/redde/photo.rb |
redde-0.4.3 | app/models/redde/photo.rb |