Anchor should not be appended when set to nil/false.

Fixes https://github.com/rails/rails/issues/17714.
Could the `to_s` be removed? Is `to_param` always supposed to return String?