Hi,
I need to build these conditions to find items in the DB:
cond_selection = { }
cond_selection[:public]=true
(cond_selection[:license_id]=1 OR cond_selection[:license_id]=3)
@guides=Guide.find(:all,:order=>‘title’,:conditions=>cond_selection)
In other words, I need to collect all the items that have license_id=1
OR license_id=3.
This string:
cond_selection[:license_id]=1 OR cond_selection[:license_id]=3
doesn’t work!
How can I do?
Thank you very much!
Luigi
This string:
cond_selection[:license_id]=1 OR cond_selection[:license_id]=3
doesn’t work!
Hmm. Perhaps better asked in the rails list but I’ll give it a shot.
since it’s two values for one variable, and a hash maps one to one,
you’ll need to use an array [sorry]–at least AFAIK.
So
cond_selection = [“public = ? and (license_id = ? or license_id = ?)”,
true, 1, 3]
something like that.
I’m sure there are helpers out there to make that less annoying to use,
though I don’t see any listed as gems per se.
GL.
=r