ruby-on-railsacts-as-listacts-as-paranoid

Acts as paranoid gem interferes with acts as list


I use both acts_as_paranoid and acts_as_list for the same model, CheckIn. I have the gem setup as follows:

class CheckIn < ActiveRecord::Base
    acts_as_paranoid
    belongs_to :client

    acts_as_list scope: :client, column: :week, top_of_list: 0
end

The ordering is scoped to the check_ins client, and I use my week column for the order. If I create a check_in, its :week => 0. If I create another, its :week => 1. The issue arises when I destroy that second check_in and then create a third, its :week => 2.

Now when I look at all the check_ins for this client, the week numbers jump from 0 to 2. Is this the intended behavior or can I do something to make the weeks sequential?


Solution

  • From this blog, try:

    acts_as_list scope: 'client_id = #{client_id} AND deleted_at IS NULL', column: :week, top_of_list: 0