No, this is not a real Sinatra error :).
This is the personal homepage of Elad Meidar, a web developer and an entrepreneur specializing in Ruby on Rails. I hang around in Israel, and i am currently having the best time of my life over at Fiverr.com
I am a proud member of RailsBridge, Helping new Rails developers get into our world and also contributed a few Patches to the Ruby on Rails core.
Few people understand the true mentality of dealing with a Boolean variable.
The normal programmer will panic, and immediately attempt to compare it to a Boolean constant.
when using Rails, This is wrong.
When migrating a boolean typed column using Rails, the actual column type created is “tinyint(1)” (a single digit number presentation which means that the actual value being saved is 0’s or 1’s.
Where is the problem? in Ruby for a change.
In Ruby, everything except nil and false is considered to a true value. In C, Python and many other languages, 0 and possibly other values, such as empty lists, are considered as false.
which brings us to the inevitable conclusion, that simplay comparing boolean values to true or false will not do.
Rails solves this tiny issue for us, for each boolean attribute, Rails implements a “query method” as i prefer to call them. These query methods are simply called by issuing the boolean attribute name with a “?” suffix.
for example, the
mail_message</span> instance object has a <span style="font-weight: bold;">is_important</span> boolean attribute, so instead of doing:<br /><br /><code><br />mail_message.is_important == true
or whatever, we can simply ask rails by:
<br />@mail_message.is_important?<br />
beautiful… isn’t it?
You're seeing this error because I think it is funny.