Element[Rationals]
does not return True
or False
for real values. For example

So your function was returning unevaluated for all the values between -5 and 5, since Plot was using real values for x in its sampling.
data = Table[{i, f[i]}, {i, -5, 5, .1}]

And plot did not know how to plot the above.
You can always check the function using a Table command, such as
data = Table[{i, f[i]}, {i, -5, 5, .1}]
To see what values it generates.