Skip to content

Commit b6aa070

Browse files
Merge pull request #12 from cortex-cms/COR-224-Edit-Existing-Assets
COR-224: Edit Existing Assets
2 parents a64b712 + a6f65a9 commit b6aa070

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/models/asset_field_type.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ def metadata=(metadata_hash)
2020
end
2121

2222
def data=(data_hash)
23+
@existing_data = data_hash.deep_symbolize_keys[:existing_data]
2324
self.asset = data_hash.deep_symbolize_keys[:asset]
2425
end
2526

2627
def data
2728
{
2829
'asset': {
2930
'file_name': asset_file_name,
30-
'url': asset.url,
31+
'url': url,
3132
'dimensions': dimensions,
3233
'content_type': asset_content_type,
3334
'file_size': asset_file_size,
@@ -113,4 +114,8 @@ def validate_asset_size
113114
def validate_asset_content_type
114115
attachment_content_type_validator.validate_each(self, :asset, asset)
115116
end
117+
118+
def url
119+
@existing_data.empty? ? asset.url : @existing_data[:asset][:url]
120+
end
116121
end

0 commit comments

Comments
 (0)