Skip to content

Commit fd5f184

Browse files
committed
Track id for paperclip consistency
1 parent 1c75541 commit fd5f184

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

app/models/asset_field_type.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def data
3333
'content_type': asset_content_type,
3434
'file_size': asset_file_size,
3535
'updated_at': asset_updated_at
36-
}
36+
},
37+
'asset_field_type_id': id
3738
}
3839
end
3940

@@ -119,17 +120,9 @@ def existing_metadata
119120
metadata.except!(:existing_data)
120121

121122
unless @existing_data.empty?
122-
metadata[:path] = updated_url(@existing_data['asset']['url'])
123+
metadata[:path].gsub(":id", @existing_data['asset_field_type_id']) if metadata[:path]
123124
end
124125

125126
metadata
126127
end
127-
128-
def updated_url(path)
129-
# Take the parse path of the existing URL and drop the first '/',
130-
# that will be added later and we don't want to duplicate it
131-
# Then remove the old file extension and replace it with the paperclipp'd new one
132-
new_path = URI.parse(path).path.slice(1..-1)
133-
new_path.gsub(File.extname(path), ".:extension")
134-
end
135128
end

0 commit comments

Comments
 (0)