50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/qcontent/assets.rb', line 50
def save_assets
logger.debug '== Saving Assets'
return unless @assets_to_save
@assets_to_save.each do |group_name, asset_group|
logger.debug '--- Deleting the whole group'
self.send("content_#{group_name}").delete_all
logger.debug "--- Saving Asset group #{group_name} on #{self}"
asset_group.each do |position, asset_attributes|
logger.debug "---- #{position}: #{asset_attributes.inspect}"
if asset_attributes.is_a?(Hash)
asset = Asset.create({:dir => group_name.to_s}.merge(asset_attributes))
self.content_assets.create(:asset_id => asset.id, :position => position, :asset_group => group_name.to_s) if asset
elsif asset_attributes.to_i > 0
self.content_assets.create(:asset_id => asset_attributes.to_i, :position => position, :asset_group => group_name.to_s)
end
end
end
end
|