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.

$\begingroup$ What is the relevance of algebraic geometry tag here? Do you have anything in mind which you did not say here? $\endgroup$– Praphulla KoushikApr 21, 2020 at 15:44

4$\begingroup$ @PraphullaKoushik the algebraic geometry tag is often relevant to commutative algebra questions. Here there's an obvious reformulation of the question in terms of affine schemes. $\endgroup$– YCorApr 21, 2020 at 16:05

$\begingroup$ @YCor Oh. Answer of SashaP also supports your comment.. I can not see immediately the affine scheme version of this question.. I will think little more to see if I can write this in terms of affine schemes $\text{Spec}(R)$.. $\endgroup$– Praphulla KoushikApr 21, 2020 at 16:59
1 Answer
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.