John Smith
John Smith

Reputation: 6259

Except in rails not working

I have this code:

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

Somehow the .except(@note) is not working, i get no error, but @note is still contained in @notes What do i wrong? Thanks!

Upvotes: 0

Views: 306

Answers (1)

jimworm
jimworm

Reputation: 2741

except is used to skip parts of your query, as in .except(:where) to skip the where clause. You might want to use something like .where('notes.id != ?', @note.id) instead. Or in Rails 4, where.not.

Upvotes: 2

Related Questions