|
|
|
@@ -6,6 +6,7 @@ class Document < ApplicationRecord |
|
|
|
|
|
|
|
has_attached_file :doc, |
|
|
|
{ |
|
|
|
styles: { thumb: ["200x", :png] }, |
|
|
|
adapter_options: { hash_digest: Digest::SHA256 }, |
|
|
|
url: "/system/:class/:attachment/:id_partition/:style/:hash.:extension", |
|
|
|
hash_secret: Rails.application.secrets.secret_key_base |
|
|
|
@@ -15,7 +16,7 @@ class Document < ApplicationRecord |
|
|
|
after_save :generate_content |
|
|
|
|
|
|
|
scope :contains_word, -> (word) { joins(:content).where("text like ?", "%#{word}%") } |
|
|
|
|
|
|
|
scope :belongs_to_category, -> (category_id) { where(category_id: category_id ) } |
|
|
|
|
|
|
|
private |
|
|
|
def generate_content |
|
|
|
|