Sha256: d07eb6296b9d304dd43e7cbb5310f9d8e2699a40b76d33d736e8c7842df94402

Contents?: true

Size: 499 Bytes

Versions: 13

Compression:

Stored size: 499 Bytes

Contents

require 'carrierwave/mongoid'

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

  private
  def update_asset_attributes
    self.file_size = asset.file.size
    self.file_type = asset.file.content_type
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
loyal_rails_kindeditor-0.0.9 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
loyal_rails_kindeditor-0.0.8 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
loyal_rails_kindeditor-0.0.7 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
loyal_rails_kindeditor-0.0.6 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
loyal_rails_kindeditor-0.0.5 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
rails_kindeditor-0.3.20 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
loyal_rails_kindeditor-0.0.4 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
loyal_rails_kindeditor-0.0.3 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
loyal_rails_kindeditor-0.0.2 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
loyal_rails_kindeditor-0.0.1 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
rails_kindeditor-0.3.19 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
rails_kindeditor-0.3.18 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb
rails_kindeditor-0.3.17 lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb