Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActiveRecord mount_uploader causes private method removal from receiver #2490

Open
scashin133 opened this issue Jun 4, 2020 · 1 comment

Comments

@scashin133
Copy link

This issue is a little deep but I'll attempt to explain. I was able to reproduce this problem with a spec in the activerecord_spec file by adding the folling under the describe '#mount_uploader' do block:

context "model has private methods" do
  before do
    Event.define_method(:test_a_method) {}
    Event.send(:private, :test_a_method)
  end

  it "maintains private methods after singleton method is called" do
    expect(@event.private_methods(false)).to include(:test_a_method)
    @event.singleton_class
    expect(@event.private_methods(false)).to include(:test_a_method)
  end
end

This spec fails on the second expect call since test_a_method no longer gets returned. This is causing issues for us due to the use of the workflow gem. Specifically the has_callback? method stopped being able to find the private methods in our models. The private method is still there is true is passed instead but the purpose of the code in the workflow gem is to only load private methods in the immediate class.

If I revert the changes done in eb9c52e then this code works again. I am still unsure as to why loading the singleton class would cause the private method to no longer show up on the receiver. I will continue attempting to find a fix, but I wanted to post this issue to see if others have ideas for how to address this problem.

Let me know if you'd prefer a PR showcasing the spec and how it fails.

@danielricecodes
Copy link

I'm pretty concerned no one is replying to these issues. Is this gem abandonware now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants