Remove CurrentUser.ip_addr.
Remove the `CurrentUser.ip_addr` global variable and replace it with `request.remote_ip`. Before we had to track the current user's IP in a global variable so that when we edited a post for example, we could pass down the user's IP to the model and save it in the post_versions table. Now that we now longer save IPs in version tables, we don't need a global variable to get access to the current user's IP outside of controllers.
This commit is contained in:
@@ -217,14 +217,13 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
end
|
||||
|
||||
current_user = CurrentUser.user
|
||||
current_ip = CurrentUser.ip_addr
|
||||
|
||||
find_in_batches(batch_size: batch_size, error_on_ignore: true) do |batch|
|
||||
Parallel.each(batch, in_processes: in_processes, in_threads: in_threads) do |record|
|
||||
# XXX In threaded mode, the current user isn't inherited from the
|
||||
# parent thread because the current user is a thread-local
|
||||
# variable. Hence, we have to set it explicitly in the child thread.
|
||||
CurrentUser.scoped(current_user, current_ip) do
|
||||
CurrentUser.scoped(current_user) do
|
||||
yield record
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user