我正在把头撞到墙上——我在 ActiveRecord 中使用各种范围,有些工作,有些没有,我不知道为什么。希望有人给我一个提示/解决方案。所有范围陈述都在同一个模型 - PortfolioProject 中。所有都被调用如下:
PortfolioProject.<scope name>(Time.zone.now).order('sequence')
这个有效 - 每次都没有失败:
scope :in_discovery, lambda {|curTime| where('sequence > 0 AND ? BETWEEN crnt_discovery_start AND crnt_discovery_finish', curTime) }
以下失败并给出错误消息:Time#succ 已过时;使用时间 + 1
scope :in_requirements, lambda {|curTime| where('sequence > 0 AND ? BETWEEN crnt_requirements_start AND crnt_requirements_finish', curTime) }
scope :in_tech_design, lambda {|curTime| where('sequence > 0 AND ? BETWEEN crnt_tech_dsgn_start AND crnt_tech_dsgn_finish', curTime) }
scope :in_development, lambda {|curTime| where('sequence > 0 AND ? BETWEEN crnt_development_start AND crnt_development_finish', curTime) }
scope :in_testing, lambda {|curTime| where('sequence > 0 AND ? BETWEEN crnt_testing_start AND crnt_testing_finish', curTime) }
scope :in_launch, lambda {|curTime| where('sequence > 0 AND ? BETWEEN crnt_launch_start AND crnt_launch_finish', curTime) }
范围语句的构造是相同的——除了每个语句中使用的列名。
我很感激任何洞察我可能做错了什么。