Cool, thanks. My IDE was moaning when I did something similar to that.
One should not always trust the IDE I guess, or does it have something
to do with the fact that you moved the constant to the end?
I'm not sure how your code was, but you can do this as well:
@states = States.find(:all, :conditions => ["country=? OR country=?",
LOCALE, 'International'])
It's just an array where every question mark will get replaced with
it's successive array element after having being Escaped by Rails.
So the first <?> gets replaced with the 2nd element
The second <?> with the 3rd element
And so on
I'm not sure how your code was, but you can do this as well:
@states = States.find(:all, :conditions => ["country=? OR country=?",
LOCALE, 'International'])
It's just an array where every question mark will get replaced with
it's successive array element after having being Escaped by Rails.
So the first <?> gets replaced with the 2nd element
The second <?> with the 3rd element
And so on
Jan
You have a special case there -- one column with any of a set of values. For that, you can use the SQL 'IN' operation like this:
States.find(:all, :conditions => ['country IN (?)', [LOCALE, 'International']] )
If you had more,
countries = [ ...all the ones you needed... ]
States.find(:all, :conditions => ['country IN (?)', countries] )
It will work with an array having just one element also.