RAILS, HAML : How to put Checkbox and label on the same line, with translations

Hey guys!

Today I have decided to share with you little secret, that can save you quite some time, while writing templates with HAML.

While creating a form for one of the projects, I needed to put a checkbox within the same line as label and also I had to make my label a “translation”.

I googled and the closest which I was able to find was:


However, It didn’t really solve my “translation” problem.

Initially my code looked like this:

.send_email in this case is a translation from my eng.yml file which equals to “Send credentials to user by email”.

The code produced this output:


However, what I needed my checkbox and message to be on the same line. This is how I was able to solve it:


(Sorry if wordpress screwed indentation!!!)

And here is how output looks like:


That’s it for today!

Have a wonderful day!



Anatoly Spektor

IT Consultant with 6 years experience in Software Development and IT Leadership. Participated in such projects as Eclipse IDE, Big Blue Button, Toronto 2015 Panam Games.

Join the Discussion

Your email address will not be published. Required fields are marked *