def sort
      element_order = params.fetch "element_order"

      element_order.each_with_index do |element_id, index|
        element = Element.find_by_id element_id
        element.update_attribute :position, index+1
      end

      head :no_content
    end
def sort
      element_order = params.fetch "element_order"

      element_order.each_with_index do |element_id, index|
        element = Element.find_by_id element_id
        element.update_attribute :position, index+1
      end

      head :no_content
    end
PUT /elements/sort