Override user methods

AI-generated summary

Here is a summary of the posts on the “Override user methods” discussion:

pfaffman is trying to prevent saving user IP addresses in Discourse, as per someone’s request. However, the IP addresses are directly saved to the database, bypassing ActiveRecord, so callbacks won’t work. To override the User.update_ip_address method, they have tried:

  1. Code in the plugin.rb file to include the OverrideUser module
  2. The OverrideUser module itself in lib/mask_ip_module/override_user.rb

Despite this, the overridden methods don’t seem to be getting called. User.my_test doesn’t work, and puts statements in User.update_ip_address are not being executed. pfaffman suspects an issue with file naming, capitalization, or some other trivial but difficult-to-spot problem is preventing the code from loading properly.

I’m trying to not save user IP addresses because that’s what someone wants.

I can’t use a callback because IP addresses are saved by directly modifying the database and not through Rails ActiveRecord.

I’m trying to override the User update_ip_address method(s).

I’m doing this:

and this:

But it seems like my stuff isn’t getting loaded. I can’t call User.my_test and when I call User.update_ip_address my puts arren’t happending.

My guess is that I have a file with the wrong name or I need to capitalize something or something else that is both trivial and impossible to figure out.