Querying in Rails with multiple hash conditions -


i'm referring hash conditions described here. use multiple types of hash conditions? equality , subset? tried it, , it's giving me syntax error:

@colleges = college.where(category: "#{@university_type}" , "us_news_ranking < #{@rank_low}").first 

is possible this, or code wrong?

is possible this, or code wrong?

your code wrong. and isn't involved in this; if want several conditions, supply several several keys/values where. in case, need 2 where calls - 1 equality condition, , 1 less-than condition.

you should never interpolate values directly string. use placeholders activerecord can escape them , prevent sql injection.

@colleges = college.where(category: @university_type).where("us_news_ranking < ?", @rank_low).first 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -