Sha256: 848086530f7c5c0ff123e95df7c86edcc32bfd7a7724bf71fe182b6cf1f596fd

Contents?: true

Size: 539 Bytes

Versions: 5

Compression:

Stored size: 539 Bytes

Contents

require 'carrierwave/mongoid'

class Kindeditor::Asset 
  self.collection_name = 'kindeditor_assets'
  include Mongoid::Document
  include Mongoid::Timestamps
  mount_uploader :asset
  field :file_size, :type => Integer
  field :file_type, :type => String
  validates_presence_of :asset
  before_save :update_asset_attributes
  attr_accessible :asset

  private
  def update_asset_attributes
    if asset.present? && asset_changed?
      self.content_type = asset.file.content_type
      self.file_size = asset.file.size
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_kindeditor-0.3.5 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
rails_kindeditor-0.3.4 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
rails_kindeditor-0.3.3 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
rails_kindeditor-0.3.2 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
rails_kindeditor-0.3.1 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb