Displaying 1 result from an estimated 1 matches for "attributes_hash".
2009 Aug 07
2
paperclip model fails while when updating with no attachment
...ow code in my item model:
[code]
after_save create_or_update_assets!
def create_or_update_assets!
# return if there are no asset_attributes
return true if asset_attributes.nil? || asset_attributes.empty?
# pull the attributes from the instance variable
asset_attributes.each do |attributes_hash|
attributes_hash.symbolize_keys!
# if atts_hash has an id (asset already exists). If there''s no id
then this is a new asset.
asset = attributes_hash[:id].blank? ? assets.build : assets.detect
{ |product| product.id == attributes_hash[:id].to_i }
asset.attachment =...