开发者

How Do I Create an 'OR' Condition Using the ActiveRecord Model

开发者 https://www.devze.com 2022-12-30 00:08 出处:网络
Given the following code which creates an and condition, how do I make it create an or condition instead?

Given the following code which creates an and condition, how do I make it create an or condition instead?

Country.first(:conditions=>{:media_code=>countr开发者_运维技巧y_code, :code=>country_code})


You can do that with array style conditions:

Country.first(:conditions => ["media_code = :code or code = :code", {:code => country_code}])
0

精彩评论

暂无评论...
验证码 换一张
取 消