TITLE: Commutative ring $R$ with no nontrivial idempotents, with a localization $R_r$ with infinitely many idempotents
QUESTION [8 upvotes]: I am looking for a commutative ring $R$ with $1$ such that $R$ has no idempotents and there exists $r\in R$ such that the localization ring $R_r$ has infinitely many idempotents.

REPLY [17 votes]: Let $k$ be a field and take $$R=\{(a_i)\in\prod\limits_{i\in\mathbb{N}}k[t]\mid a_i(0)=a_j(0)\text{ for all }i,j\}$$
An idempotent in this ring has to be sent to $0$ or $1$ under the map $R\xrightarrow{(a_i)\mapsto a_i(0)}k$ hence has to be equal to $(0,0,...)$ or $(1,1,..)$. However, if we invert $r=(t,t,t,..)$ then each of the elements $(0,\dots,0,t,0,\dots)r^{-1}$ gives an idempotent in the localization.
Geometrically, this is analogous (but is not exactly equivalent as taking spectrum does not take infinite products to disjoint unions) to gluing infinitely many affine lines by their origins to get something connected that splits into infinitely many connected components after removing the origin.