app/models/ckeditor/asset.rb in georgia-0.7.8 vs app/models/ckeditor/asset.rb in georgia-0.8.0
- old
+ new
@@ -1,25 +1,29 @@
class Ckeditor::Asset < ActiveRecord::Base
- include Georgia::Indexer::Adapter
+ include Elasticsearch::Model
+ include Elasticsearch::Model::Callbacks
+ index_name 'ckeditor-assets'
+ document_type 'asset'
+ include Ckeditor::AssetSearch
# to allow media_path in to_jq_upload
include Georgia::Engine.routes.url_helpers
include Ckeditor::Orm::ActiveRecord::AssetBase
- include Georgia::Concerns::Taggable
+ acts_as_taggable_on :tags
+
delegate :url, :current_path, :content_type, to: :data
mount_uploader :data, Ckeditor::AttachmentFileUploader, mount_on: :data_file_name
validates :data, presence: true
- attr_accessible :data
paginates_per 15
- scope :latest, order('created_at DESC')
+ scope :latest, -> { order(created_at: :desc) }
def to_jq_upload
{
"name" => read_attribute(:data),
"size" => data.size,
@@ -34,9 +38,17 @@
end
def extension
self.data_content_type ||= self.data.file.content_type
@extension ||= data_content_type.gsub(/.*\/(.*)/, '\1')
+ end
+
+ def self.policy_class
+ Georgia::MediaPolicy
+ end
+
+ def image?
+ false
end
SIZE_RANGE = {
'< 25 KB' => 0..25,
'25 KB to 100 KB' => 25..100,
\ No newline at end of file