I want to search through users whose show attribute is true.
show = true
@users = User.find(:all,
:conditions => ["show = ?", show])
This doesn't appear to be working for me.
Your example should definitely work. If you're running an older version of rails you may need to restart your server.
Another option is to use the hash syntax like...
@users = User.find(:all, :conditions => {:show => true})
Then you can just add your other conditions within the hash.
Try an alternative version of the query:
User.find_all_by_show(true)
Make sure the users table has a tinyint(1)(i.e. boolean) column called show.
I have seen this behavior before. I had to use 1/0 for true false for array conditions. Try this:
show = 1
@users = User.find(:all,
:conditions => ["show = ?", show])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With