Sha256: 49fb96e6e64a97b3c5ede5211dd3e7ca056b03f40b321c70c56f497e2b2ef455

Contents?: true

Size: 498 Bytes

Versions: 1

Compression:

Stored size: 498 Bytes

Contents

class Models::Item
  def attachments
    @attachments ||= []
  end
  mount_attachments(:attachments, :file){Models::Attachment.new}

  assign :attachments_as_attachments, true

  def attachments_as_images
    # TODO3 remove sorting, use order defined in database
    _cache[:attachments_as_images] ||= attachments.
      sort{|a, b| a.file.name <=> b.file.name}.
      collect{|o| {name: o.file.name, url: o.file.url, thumb_url: o.file.thumb.url, icon_url: o.file.icon.url}.to_openobject}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rad_kit-0.0.10 app/models/_item/attachments.rb