@@ -57,11 +57,23 @@ def from_attachable_sgid(sgid)
57
57
ActionText ::Attachable . from_attachable_sgid ( sgid , only : self )
58
58
end
59
59
60
+ # Returns the path to the partial that is used for rendering missing attachables.
61
+ # Defaults to "action_text/attachables/missing_attachable".
62
+ #
63
+ # Override to render a different partial:
64
+ #
65
+ # class User < ApplicationRecord
66
+ # def self.to_missing_attachable_partial_path
67
+ # "users/missing_attachable"
68
+ # end
69
+ # end
60
70
def to_missing_attachable_partial_path
61
71
ActionText ::Attachables ::MissingAttachable ::DEFAULT_PARTIAL_PATH
62
72
end
63
73
end
64
74
75
+ # Returns the Signed Global ID for the attachable. The purpose of the ID is
76
+ # set to 'attachable' so it can't be reused for other purposes.
65
77
def attachable_sgid
66
78
to_sgid ( expires_in : nil , for : LOCATOR_NAME ) . to_s
67
79
end
@@ -86,14 +98,35 @@ def previewable_attachable?
86
98
false
87
99
end
88
100
101
+ # Returns the attachable as JSON with the +attachable_sgid+ included.
89
102
def as_json ( *)
90
103
super . merge ( "attachable_sgid" => persisted? ? attachable_sgid : nil )
91
104
end
92
105
106
+ # Returns the path to the partial that is used for rendering the attachable
107
+ # in Trix. Defaults to +to_partial_path+.
108
+ #
109
+ # Override to render a different partial:
110
+ #
111
+ # class User < ApplicationRecord
112
+ # def to_trix_content_attachment_partial_path
113
+ # "users/trix_content_attachment"
114
+ # end
115
+ # end
93
116
def to_trix_content_attachment_partial_path
94
117
to_partial_path
95
118
end
96
119
120
+ # Returns the path to the partial that is used for rendering the attachable.
121
+ # Defaults to +to_partial_path+.
122
+ #
123
+ # Override to render a different partial:
124
+ #
125
+ # class User < ApplicationRecord
126
+ # def to_attachable_partial_path
127
+ # "users/attachable"
128
+ # end
129
+ # end
97
130
def to_attachable_partial_path
98
131
to_partial_path
99
132
end
0 commit comments