Checking if a boolean column is true in MySQL/Rails
- by Pygmalion
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!