def insert_successor(create_params, path)
      self.class.transaction do
        new_successor = self.class.create!(create_params)
        if library?
          if path
            old_successor = path.first
            old_successor.prior = new_successor
          end
          save_successor new_successor
        elsif successor.nil?
          save_successor new_successor
        else
          old_successor = successor
          old_successor.prior = new_successor
          save_successor new_successor
        end
        fail HttpErrors::UnprocessableEntity, _('An environment is missing a prior') unless all_have_prior?
        new_successor
      end
    end
def insert_successor(create_params, path)
      self.class.transaction do
        new_successor = self.class.create!(create_params)
        if library?
          if path
            old_successor = path.first
            old_successor.prior = new_successor
          end
          save_successor new_successor
        elsif successor.nil?
          save_successor new_successor
        else
          old_successor = successor
          old_successor.prior = new_successor
          save_successor new_successor
        end
        fail HttpErrors::UnprocessableEntity, _('An environment is missing a prior') unless all_have_prior?
        new_successor
      end
    end
creates new env from create_params with self as a prior