Checking if a boolean column is true in MySQL/Rails
Posted
by Pygmalion
on Stack Overflow
See other posts from Stack Overflow
or by Pygmalion
Published on 2010-05-05T21:25:42Z
Indexed on
2010/05/05
21:28 UTC
Read the original article
Hit count: 194
ruby-on-rails
|mysql
Rails and MySQL:
I have a table with several boolean columns representing tags. I want to find all the rows for which a specific one of these columns is 'true' (or I guess in the case of MySQL, '1'). I have the following code in my view.
@tag = params[:tag]
@supplies = Supply.find(:all, :conditions=>["? IS NOT NULL and ? !=''", @tag, @tag], :order=>'name')
The @tag is being passed in from the url. Why is it then that I am instead getting all of my @supplies (i.e. every row) rather than just those that are true for the column for @tag.
Thanks!
© Stack Overflow or respective owner