Ruby on Rails to boolean method

Ruby on Rails to boolean method

Today I discovered a very nice little gem, it´s called wannabe_bool and it is very useful. It handles cases where for example the string "true" is converted to a simple true boolean.

If string, integer, symbol and nil values wanna be a boolean value, they can with the new to_b method from wannabe_bool. Moreover, you can use WannabeBool::Attributes module to create predicate methods in your classes.

More about this very convenient script can be found on github:

I know you can also code this stuff by yourself, but why you should reinvent the wheel? This gem is tested and seems to work perfect.

Have a good one ;-)


Matthias Frick
Ruby on Rails
0 Kommentare

Über den Autor

Matthias Frick
Matthias Frick, MSc.

Er ist ein langjähriger Ruby-on-Rails Entwickler und leitet das Unternehmen Frick-Web.

0 Kommentare zu "Ruby on Rails to boolean method"

Kommentar verfassen