标签: ruby-on-rails-3 ruby-on-rails-3.1
如果我这样做:
date1 = "2012-01-01".to_date @dates = (Date.today..Date.today + 60.days)
如何检查date1是否在@dates中?
答案 0 :(得分:3)
您可以使用.include?:
.include?
@dates.include?(date1)
或者在Ruby 1.9中,您也可以使用.cover?:
.cover?
@dates.cover?(date1)