Sha256: 0e86626debddde52365c8430de92a8fff37f0f1db77f0d3559a5635e04e1d740

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

module RocketCMS
  module Models
    module Mongoid
      module EmbeddedGalleryImage
        extend ActiveSupport::Concern
        include ::Mongoid::Paperclip

        included do
          #embedded_in :model # need to override

          field :name, type: String

          has_mongoid_attached_file :image # need to override
          validates_attachment :image, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }

          def image_file_name=(val)
            val = val.to_s
            return if val.blank?
            extension = File.extname(val)[1..-1]
            file_name = val[0..val.size-extension.size-1]
            self[:image_file_name] = "#{file_name.filename_to_slug}.#{extension.filename_to_slug}"
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ack_rocket_cms-0.7.4 lib/rocket_cms/models/mongoid/embedded_gallery_image.rb
ack_rocket_cms-0.7.3 lib/rocket_cms/models/mongoid/embedded_gallery_image.rb