所以我有这样用Rails 3.2.13
编写的代码,我必须在Rails 4
中进行更改。
scope :between, lambda {|start_time, end_time|
{:conditions => ["? < starts_at < ?", Event.format_date(start_time), Event.format_date(end_time)] }}
我试过这样,但没有成功。
scope :between, ->(starts_at, ends_at) { where(:starts_at => Event.format_date(starts_at), :ends_at => Event.format_date(ends_at)) }
可能是我错过了什么。请帮忙。提前谢谢。
我不知道
这是否是标准代码,但通过这种方式我已经做到了,
scope :between, lambda { |starts_at, ends_at| where("? < starts_at < ?", Event.format_date(starts_at), Event.format_date(ends_at)) }
如果我错了,请纠正我。
谢谢