Sha256: 3bfcd1f18836b4acb4ff9fed9cc445940a5373ed564ac0f48a270a690c113157

Contents?: true

Size: 791 Bytes

Versions: 8

Compression:

Stored size: 791 Bytes

Contents

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

        included do
          manual_slug :name

          acts_as_nested_set
          scope :sorted, -> { order_by([:lft, :asc]) }

          has_mongoid_attached_file :image # need to override

          def image_file_name=(val)
            return self[:image_file_name] = ""  if val == ""
            return self[:image_file_name] = nil if val == nil
            val = val.to_s
            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

8 entries across 8 versions & 1 rubygems

Version Path
ack_rocket_cms-0.9.2 lib/rocket_cms/models/mongoid/gallery.rb
ack_rocket_cms-0.9.1.3 lib/rocket_cms/models/mongoid/gallery.rb
ack_rocket_cms-0.9.1.2 lib/rocket_cms/models/mongoid/gallery.rb
ack_rocket_cms-0.9.1.1 lib/rocket_cms/models/mongoid/gallery.rb
ack_rocket_cms-0.9.1 lib/rocket_cms/models/mongoid/gallery.rb
ack_rocket_cms-0.9 lib/rocket_cms/models/mongoid/gallery.rb
ack_rocket_cms-0.8.2 lib/rocket_cms/models/mongoid/gallery.rb
ack_rocket_cms-0.8.0 lib/rocket_cms/models/mongoid/gallery.rb