lem*_*ger 1 activerecord scope named-scope ruby-on-rails
是否可以在rails模型中的范围参数中添加OR语句
scope :west_coast, where(:st => "CA" || "WA" || "OR")
Run Code Online (Sandbox Code Playgroud)
问题是如何WHERE ... IN使用activerecord 创建一个sql 语句:
scope :west_coast, where(st: %w(CA WA OR))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
51 次 |
| 最近记录: |