Overriding find_by_* methods causes error

Hi! I fixed #15288 issue. I didn't found test model for this case, because I create it myself. Please, review my code.
can you do `unless model.is_a?(anonymous_module)`