【问题标题】:Except in rails not working除了在不工作的轨道上
【发布时间】:2014-03-22 17:00:42
【问题描述】:

我有这个代码:

  @note = @patient.notes.find(params[:id])
  @notes = @patient.notes.where(jahr: @note.jahr, quartal: @note.quartal).except(@note)

不知何故.except(@note) 不起作用,我没有收到错误,但@note 仍包含在@notes 中我错了什么?谢谢!

【问题讨论】:

标签: ruby-on-rails ruby ruby-on-rails-3


【解决方案1】:

except 用于跳过部分查询,如.except(:where) 用于跳过where 子句。您可能想改用.where('notes.id != ?', @note.id) 之类的东西。或者在 Rails 4 中,where.not

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-11
    • 1970-01-01
    • 1970-01-01
    • 2011-03-05
    相关资源
    最近更新 更多