1
ShiftNote
belongs_to :shift, counter_cache: true
workflow do
state :scheduled
state :canceled
end
Shift
has_many :shift_notes
scope :opened, lambda {
locked
.where("shift_notes_count < shifts.limit")
}
如何不增加shift_notes_count
期間ShiftEntry創作時shift_note.state.canceled? => true
如何在某些狀態更改時排除遞增的counter_cache?
現在我shift_entries_count
是隻讀的。
Rails不支持有條件的計數器。 – Florent2