We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 607264f commit e7d3d99Copy full SHA for e7d3d99
app/helpers/url_decoded_attribute_helper.rb
@@ -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
8
+end
app/models/document.rb
@@ -1,9 +1,14 @@
class Document < ApplicationRecord
+ extend UrlDecodedAttributeHelper
+
belongs_to :site
has_many :workflow_histories, class_name: "DocumentWorkflowHistory"
has_paper_trail versions: {scope: -> { order(created_at: :desc) }}
9
+ url_decoded_attribute :file_name
10
+ url_decoded_attribute :url
11
12
scope :by_status, ->(status) {
13
case status
14
when "in_review"
0 commit comments