@@ -109,6 +109,7 @@ namespace :rich_text_urls_update do
109109 url = match [ regex , 1 ] # extract the actual URL
110110 aws_prefix = "https://s3.amazonaws.com/awbwassets/"
111111 aws_prefix_2 = "http://s3.amazonaws.com/awbwassets/"
112+ aws_prefix_3 = "//s3.amazonaws.com/awbwassets/"
112113 dashboard_url = nil
113114 key = nil
114115 puts url
@@ -132,6 +133,8 @@ namespace :rich_text_urls_update do
132133 key = url . sub ( aws_prefix , "" )
133134 when -> ( u ) { u . start_with? ( aws_prefix_2 ) }
134135 key = url . sub ( aws_prefix_2 , "" )
136+ when -> ( u ) { u . start_with? ( aws_prefix_3 ) }
137+ key = url . sub ( aws_prefix_3 , "" )
135138 else
136139 csv << [ model . name , record . id , column , url , nil , "skipped" , "No Matching Url" , nil ]
137140 next
@@ -151,7 +154,7 @@ namespace :rich_text_urls_update do
151154
152155 begin
153156 blob = ActiveStorage ::Blob . find_by ( aws_key : key )
154- image = record . images . build ( type : "RichTextAsset" )
157+ asset = record . rich_text_assets . build
155158 file_name = File . basename ( key )
156159 temp = nil
157160
@@ -180,14 +183,14 @@ namespace :rich_text_urls_update do
180183 )
181184 blob . update! ( aws_key : key )
182185 end
183- image . file . attach ( blob )
184- image . save!
186+ asset . file . attach ( blob )
187+ asset . save!
185188
186- new_url = url_for ( image . file )
189+ new_url = url_for ( asset . file )
187190
188191 # Verify attachment and association
189- record . images . reload
190- unless record . images . include? ( image ) && image . file . attached?
192+ record . rich_text_assets . reload
193+ unless record . rich_text_assets . include? ( asset ) && asset . file . attached?
191194 raise "Media not associated with record or file missing"
192195 end
193196 content = record . public_send ( column )
0 commit comments