Below is an excerpt of my historia-matematica post, June 16, 2001 (or sci.math May 19,2003) which presents this style of irrationality proof in an elementary form that highlights the contrast between the discreteness of a ring of (algebraic) integers
versus the denseness of a ring of fractions. See also the closely related elegant proofs using Dedekind's notion of conductor ideal.
Theorem $ $ If an integer $\,b\,$ has
a rational square root: $\sqrt b = c/d\,$ then $\,c/d\,$ is an integer.
Proof $ $ Suppose, as hypothesized $\,w = \sqrt b = c/d\,$ is rational.
$\,d\,$ is a common denominator for all elements in the ring $\,R = \Bbb Z[w]\,$
since if $\,r = m + n\:\!w \in R,\ m,n \in\Bbb Z\,$ then $\,dr = dm + n(dw)\in\Bbb Z\,$ by $\, dw = c\in\Bbb Z.\,$ So $R$ is a subset of $\,\Bbb Z/d,\,$ i.e. every $\,r \in R\,$ has form $\,n/d\,$ for an integer $\,n.\,$ Suppose $\,r = n/d\in R\,$ is nonintegral. We will show this leads to a contradiction and, hence, that every $\,r \in R = \Bbb Z[w]\,$ must be an integer, including $\,w = \sqrt b.$
W.l.o.g we may assume $\,0 < r < 1\,$ by taking the fractional part
of $|r|,\,$ since this too lies in $R$ and is nonintegral iff $\,r\,$ is.
But $\,r\,$ has form $\,n/d\,$ and $\,0 < r < 1,\,$ so $\, r\,$ is a member of the finite set $\,\{ 1/d,\, 2/d,\ldots,(d\!-\!1)/d\}.\,$ If $\,r\,$ is the smallest element of $R$ in this set then $\,r^2\,$ is an even smaller such element, since $\,1 > r > r^2 > 0,\,$ contradicting the minimality of $\,r.\ \ $ QED
Remark $ $ This proof works for any algebraic integer, i.e. any root of monic polynomial with integer coefficients
$\,p(x) = x^n + a x^{n-1} + b x^{n-2} + \cdots + k,\,\ a,b,..,k\in \Bbb Z,\,$ by
using $\,d^{n-1}$ versus $\,d\,$ as a common denominator for $\,\Bbb Z[w].\,$
It proves any rational algebraic integer is an integer (compare to the common proof by the Rational Root Test).
The proof above is special case $\,p(x) = x^2 - b.$
The proof depends crucially on the fact
that $w$ is an algebraic integer, which implies that the ring
$\,\Bbb Z[w] = Z\langle 1,w,w^2,\ldots,w^{n-1}\rangle$ is a finite dimensional $\Bbb Z$-module, i.e.
$\,w^n, w^{n+1},\ldots$ are $\,\Bbb Z$-linear combinations of $\,1, w, w^2,\ldots, w^{n-1}.\,$
This needn't be true if $w$ is a root of a poly $\,p(x)\,$ whose leading
coef $c\neq 1$ since then $\,w^n = -c^{-1} (a w^{n-1} + \ldots + k)\,$
so that $c$ may intrude as a nontrivial denominator when using this
equation to rewrite $\,w^n, w^{n+1},\ldots$ after multiplying two elts.
Essentially the proof shows that if $\,R \supset \Bbb Z\,$ is an ordered ring
extension which adjoins a new finite element then $\,R\,$ is dense,
having infinite descending chains $\, 1 > r > r^2 > r^3 > \ldots > 0\,$
in a nbhd of $0$ (hence everywhere by an additive shift), where
$\,r > 0\,$ is the fractional part of any newly adjoined finite element.
But $\,\Bbb Z/d\,$ is discrete, not dense, hence the contradiction.
Note that I say "finite" above because it is possible to adjoin
infinite elts alone, e.g. consider $\,\Bbb Z[x]\,$ with $x$ infinite, i.e.
polys in a nbhd of $+\infty$, ordered by declaring
$\,p(x) > q(x)\,$ iff this holds true eventually for all large $x > 0,$
i.e. in a nbhd of $+\infty.\,$ This is same as declaring $p(x)$ positive
or negative as is its leading coef (the leading term eventually
dwarfs others as $\,x\to +\infty)\,$ and $\,p > q \iff p - q > 0,\,$ as usual.
This ordered ring extension of $\,\Bbb Z\,$ adjoins no new finite elements.
However, if we additionally adjoin the infinitesimal $\,1/x\,$ then
we have $\, 1 > 1/x > 1/x^2 > \ldots > 0,\,$ and adding $c$ shifts this
infinitely descending chain to the nbhd of any elt $\,c \in \Bbb Z[x,1/x].$