How to output a boolean true or false to display yes or no in Ruby on Rails

Posted on 12 April 2006

So you have a boolean check in your database and you want to convert the output from saying "true" or "false" to something more readable like "yes" or "no". It's as easy as:


<%= article.show? ? 'yes' : 'no' %>

Where article is the object and show is the field in my database with the boolean 1 or 0 stored.

Comments left...

Got something to say?