This is an example from Munkres' Topology.
The definition given states that for an ordered set $X$, let us say that a subset $Y$ of $X$ is convex in $X$ if for each pair of points $a<b$ of $Y$, the entire interval $(a,b)$ of points of $X$ lies in $Y$.
Now I found a counterexample to the statement that if $Y$ is a proper subset of $X$ that is convex in $X$, it may not follow that $Y$ is an interval or a ray in $X$.
Here the set $Y$ is $\mathbb{Q}$ and $(-\sqrt{2},\sqrt{2})\cap \mathbb{Q}$ is given as a convex subset which is not an interval in $\mathbb{Q}$.
My concern is why is the set $Y$ convex in the first place? For every $a<b$, $a,b,\in \mathbb{Q}$ there would be irrationals so $(a,b) \notin Y$.
For any two rational points $a,b \in Y$ the interval $(a,b)$ is in $Y$ making it convex. In this example $X= \mathbb{Q}$ and so $(-\sqrt{2},\sqrt{2}) \cap \mathbb{Q}$ doesn't contain any irrational numbers. The reason it's not an interval is that the endpoints are not in $\mathbb{Q}$. It is the union of infinitely many rational intervals though.