Suppose $R$ is a UFD and $p(x)\in R[x]$ a polynomial of degree $\ge 1$. Suppose $\frac ab$ is in the fraction field $K$ of $R$, with $a$ and $b\in R$ and $\text{gcd}(a,b)=1$, and such it is a root of $p(x)$, so $p(\frac ab)=0$.
Question: Is it true that then we have $p(x)=(bx-a)q(x)$ with $q(x)\in R[x]$?
It is clear that $q(x)\in K[X]$ exists and it is unique. Since the highest degree coefficient of $p(X)$ is divisible by $b$ and the constant term is divisible by $a$ (e.g. the rational root theorem ) one can easily show that the highest degree coefficient and the constant term of $q(x)$ are in $R$. This shows the case $p(x)$ has degree 2.
A suspect it should a consequence of the so called Gauss Lemma, but I was not able to find a convincing argument.
Note: $\,p(x) = (bx\!-\!a)q(x) = (bx-a)\frac{c}d\bar q(x)\,$ by Factor Theorem in $K[x],\,$ $\color{#0a0}{{\rm primitive} \ \bar q}\in R[x]$
thus $\, d p(x) = (bx\!-\!a)\, c\,\color{#0a0}{\bar q(x)},\,$ so taking $C = $ content of this
$\Rightarrow\, d\,C(p(x))\ =\ 1\cdot c\cdot\color{#0a0} 1,\, $ i.e. $\,d\mid c\,$ in $\,R,\,$ so $\,q = \frac{c}d \bar q\in R[x].\ \ $ QED
Or by nonmonic Division: $\, b^k p(x) = (bx\!-\!a) q(x) + r,\ r\in R,\,$ so $\,r = 0\,$ by eval at $\,x = a/b.\,$ Note $\color{#c00}{(b,bx\!-\!a)}=\color{#0a0}{(b,a)}=\color{#c00}1,\,$ so $\,\color{#c00}{b\mid (bx\!-\!a)}q(x)\,\overset{\rm Euclid}\Longrightarrow\,b\mid q(x),\,$ thus $\,b^k\mid q(x)\,$ by induction [or we can use localization or the AC method as described in the link]. This proof works not only when $R$ is a gcd domain, but also when the ideal $\,\color{#0a0}{(b,a)}=(1)\,$ in any commutative ring $R.\,$ See also here.