【问题标题】:syntax error, unexpected keyword_or scope语法错误,意外的关键字或范围
【发布时间】:2014-03-12 11:35:00
【问题描述】:

我正在运行Feed.history,但由于我在Feed 模型中使用的scope 行,它在标题中引发了上述错误:

scope :history, -> { or({:end.ne => nil}, {:end.lt => Time.current}) }

什么和为什么?!!

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 mongoid syntax-error mongoid4


    【解决方案1】:

    试试这个

    scope :history, where('$or' => [{:end.ne => nil}, {:end.lt => Time.current}])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-05
      • 1970-01-01
      • 2015-06-12
      • 1970-01-01
      • 2015-12-11
      • 1970-01-01
      相关资源
      最近更新 更多