Skip to content

Commit e7d3d99

Browse files
committed
Add fix for special characters in filenames and urls.
1 parent 607264f commit e7d3d99

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module UrlDecodedAttributeHelper
2+
def url_decoded_attribute(attribute)
3+
define_method(attribute) do
4+
return nil if self[attribute].nil?
5+
CGI.unescape(self[attribute])
6+
end
7+
end
8+
end

app/models/document.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
class Document < ApplicationRecord
2+
extend UrlDecodedAttributeHelper
3+
24
belongs_to :site
35
has_many :workflow_histories, class_name: "DocumentWorkflowHistory"
46

57
has_paper_trail versions: {scope: -> { order(created_at: :desc) }}
68

9+
url_decoded_attribute :file_name
10+
url_decoded_attribute :url
11+
712
scope :by_status, ->(status) {
813
case status
914
when "in_review"

0 commit comments

Comments
 (0)