Rails:什么是我的'在ActiveRecord里面的类

时间:2014-12-18 11:39:35

标签: ruby-on-rails activerecord squeel

这很奇怪。我没有看到任何关于在课程中使用'my'的文档。任何人都可以解释下面的内容。

1.9.3-p547 :006 >  reser = Date.today
 => Thu, 18 Dec 2014
1.9.3-p547 :011 > Reservation.where { start_date >= reser }.count
   (0.8ms)  SELECT COUNT(*) FROM "reservations" WHERE "reservations"."start_date" >= '2014-12-18'
 => 63
1.9.3-p547 :012 > Reservation.where { start_date >= my { reser } }.count
   (0.8ms)  SELECT COUNT(*) FROM "reservations" WHERE "reservations"."start_date" >= '2014-12-18'
 => 63 

1 个答案:

答案 0 :(得分:1)

它来自扩展AR的squeel gem。请参阅Query DSL