My small service in Rails
class ReadUserService
def self.read_users(count)
users = Users.inactive.limit(count)
users.update_all(status: User.statuses[:active])
users.to_a
end
end
When I not call update_all
, users
variable is correctly, but When I use update_all
, my users
variable is empty. How Can I stopped clear my array? I need return all users from db, which have inactive status before update_all
update_all
returns the count of no of record updated.users.update_all(status: User.statuses[:active])
withUsers.inactive.limit(count).update_all(status: User.statuses[:active])
I hope this will work