How can I put that code in one line?

If you move the some of it to the helper, you can do this

HELPER