torrentdu64 The limit and offset is to grab the number of records to be "deactivated"
limit = user.books.count - user.resource_limit this is getting the total number of books and subtracting the soft limit that the user has set. So if there are 10 books and the user is allowed to have 4 then the limit will be set to 6. "limit" is probably a bad name because it really is number_of_books_over_the_limit.
The limit method will only return that number of books (performing a SQL LIMIT) whereas offset will return all of the records, offsetting from whatever number it is.So, in this case, we deactivated the records up to 6, but then activated the rest of them (offsetting from 6), so that should be the 4 allowed records within the soft limits implementation.