Sha256: 36d4220f4173626fd380ff9d8d1b24597b48fddd3aa870b6c7766c8c2e06b9bd

Contents?: true

Size: 1.56 KB

Versions: 6

Compression:

Stored size: 1.56 KB

Contents

module ContentsCore
  class ItemFile < Item
    # has_attached_file :data_string
    # validates_attachment_content_type :data_string, content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif']

    # include Mongoid::Paperclip
    # has_mongoid_attached_file :data
    # validates_attachment_content_type :data, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]

    # mount_uploader :data_file, ::FileUploader

    alias_attribute :data, :data_file

    def editable
      ContentsCore.editing ? { 'data-ec-item': self.id, 'data-ec-input': self.opt_input, 'data-ec-type': self.class_name, 'data-ec-block': self.block_id } : {}
    end

    def init
      # self.data_file = File.open( ContentsCore::Engine.root.join( 'lib', 'data', 'img1.jpg' ) )
      self
    end

    def self.permitted_attributes
      [ :data_file ]
    end

    def self.type_name
      'file'
    end

    # before_validation :on_before_validation
    #
    # def on_before_validation
    #   self.data = File.open( 'rails/editable_components_test/public/img/img1.jpg' )
    #   # binding.pry
    # end

    # before_save :on_before_save
    # before_validation :on_before_validation
    # before_create :on_before_create
    # before_update :on_before_update
    # before_upsert :on_before_upsert
    #
    # def on_before_save; p '>>> before_save'; end
    # def on_before_validation; p '>>> before_validation'; end
    # def on_before_create; p '>>> before_create'; end
    # def on_before_update; p '>>> before_update'; end
    # def on_before_upsert; p '>>> before_upsert'; end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contents_core-0.2.5 app/models/contents_core/item_file.rb
contents_core-0.2.4 app/models/contents_core/item_file.rb
contents_core-0.2.2 app/models/contents_core/item_file.rb
contents_core-0.2.0 app/models/contents_core/item_file.rb
contents_core-0.1.9 app/models/contents_core/item_file.rb
contents_core-0.1.8 app/models/contents_core/item_file.rb