app/models/alchemy/attachment.rb in alchemy_cms-7.0.0.pre.a vs app/models/alchemy/attachment.rb in alchemy_cms-7.0.0.pre.b
- old
+ new
@@ -38,11 +38,11 @@
has_many :elements, through: :file_ingredients
has_many :pages, through: :elements
scope :by_file_type, ->(file_type) { where(file_mime_type: file_type) }
scope :recent, -> { where("#{table_name}.created_at > ?", Time.current - 24.hours).order(:created_at) }
- scope :without_tag, -> { left_outer_joins(:taggings).where(gutentag_taggings: { id: nil }) }
+ scope :without_tag, -> { left_outer_joins(:taggings).where(gutentag_taggings: {id: nil}) }
# We need to define this method here to have it available in the validations below.
class << self
# The class used to generate URLs for attachments
#
@@ -60,16 +60,16 @@
def alchemy_resource_filters
[
{
name: :by_file_type,
- values: distinct.pluck(:file_mime_type).map { |type| [Alchemy.t(type, scope: "mime_types"), type] }.sort_by(&:first),
+ values: distinct.pluck(:file_mime_type).map { |type| [Alchemy.t(type, scope: "mime_types"), type] }.sort_by(&:first)
},
{
name: :misc,
- values: %w(recent last_upload without_tag),
- },
+ values: %w[recent last_upload without_tag]
+ }
]
end
def last_upload
last_id = Attachment.maximum(:id)
@@ -77,11 +77,11 @@
where(id: last_id)
end
def searchable_alchemy_resource_attributes
- %w(name file_name)
+ %w[name file_name]
end
def allowed_filetypes
Config.get(:uploader).fetch("allowed_filetypes", {}).fetch("alchemy/attachments", [])
end
@@ -104,10 +104,10 @@
def to_jq_upload
{
"name" => read_attribute(:file_name),
"size" => read_attribute(:file_size),
- "error" => errors[:file].join,
+ "error" => errors[:file].join
}
end
def url(options = {})
if file