6
7
8
9
10
11
12
13
14
|
# File 'app/models/featured_work_list.rb', line 6
def featured_works_attributes=(attributes_collection)
attributes_collection = attributes_collection.to_h if attributes_collection.respond_to?(:permitted?)
attributes_collection = attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes } if attributes_collection.is_a? Hash
attributes_collection.each do |attributes|
raise "Missing id" if attributes['id'].blank?
existing_record = FeaturedWork.find(attributes['id'])
existing_record.update(attributes.except('id'))
end
end
|