Sha256: c36b3c6d3b3364bbaa58442bcc40b1ac83f14008142fbcbe10ca08a9bc1f7802
Contents?: true
Size: 653 Bytes
Versions: 3
Compression:
Stored size: 653 Bytes
Contents
class AssetAttachment < ActiveRecord::Base belongs_to :asset belongs_to :assetable, polymorphic: true before_validation :ensure_name_is_not_blank before_save :set_sort_order # Is the asset_attachment attached to a gallery? def gallery? assetable_type.downcase == "gallery" end def gallery assetable end private # Ensure the name is not blank to avoid unique indexes on the name # If it's blank, let's set it to nil def ensure_name_is_not_blank name = nil if name.blank? end def set_sort_order sort_order = assetable.asset_attachments.size if gallery? and sort_order.blank? end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
assetable-0.2.4 | app/models/asset_attachment.rb |
assetable-0.2.2 | app/models/asset_attachment.rb |
assetable-0.2.1 | app/models/asset_attachment.rb |