app/models/faq.rb
# If the order chosen exists already or if it's not present, it adds it to the last position
If the order chosen exists already or if it's not present, it adds it to the last position
If the order chosen exists already or if it ' s not present it adds it to the last position
def check_order
    return if order.present? && Faq.where(order: order).where.not(id: id).empty?
    self.order = begin
                   Faq.order(order: :desc).limit(1).first.order + 1.0
                 rescue
                   1
                 end
  end
def check_order return if order . present? && Faq . where ( order : order ) . where . not ( id : id ) . empty? self . order = begin Faq . order ( order : :desc ) . limit ( 1 ) . first . order + 1.0 rescue 1 end end
If the order chosen exists already or if it's not present, it adds it to the last position
If the order chosen exists already or if it ' s not present it adds it to the last position