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

remove deprecated custom_parent code #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brchristian
Copy link
Contributor

@brchristian brchristian commented Jan 31, 2017

This removes the custom parent class code recently deprecated in #56.

I figure we don’t need to merge this right away, because #56 was just merged to master, but I wanted to make the PR while it was all still fresh in my mind. Nothing urgent, but we can merge whenever the timing makes sense.

Tests remain green, and this should not affect behavior (other than removing custom parent classes).

@rafaelfranca
Copy link

Hey, I was trying to upgrade my app to Rails 5 and found this deprecation warning everywhere. It seems that is not caused by anything in my code since the method is being called internally. Can we merge it?

Nothing urgent, but we can merge whenever the timing makes sense.

I'd say it is urgent since master is the only version that support Rails 5 and this deprecation is being show to the users and there is nothing they can do to fix the deprecation.

@brchristian
Copy link
Contributor Author

@rafaelfranca I certainly won’t argue with getting this merged. :) In the meantime, are you setting custom_parent_classes anywhere in your code? That was being used by many people as a workaround for the STI and ActiveRecord::Base issues which were addressed by #56. If so, I suspect (without knowing for sure) that you can now remove any custom_parent_classes and you’d see those deprecation warnings disappear.

@rafaelfranca
Copy link

No, we don't have any calls for custom_parent_classes and parent_classes in our codebase. The only call is inside the gem lib/acts_as_follower/follower_lib.rb:10 and it is being called in

params = {followable_id: followable.id, followable_type: parent_class_name(followable)}
. So seems the gem is showing deprecation messages for the codebase that the gem itself is calling.

@brchristian
Copy link
Contributor Author

The chain that I’m seeing looks like https://github.com/tcocca/acts_as_follower/blob/master/lib/acts_as_follower/follower.rb#L32 calls parent_class_name, as you note. That method is at

def parent_class_name(obj)
unless parent_classes.include?(obj.class.superclass)
return obj.class.base_class.name
end
obj.class.name
end
, which then calls parent_classes, which is at
def parent_classes
return DEFAULT_PARENTS unless ActsAsFollower.custom_parent_classes
ActiveSupport::Deprecation.warn("Setting custom parent classes is deprecated and will be removed in future versions.")
ActsAsFollower.custom_parent_classes + DEFAULT_PARENTS
end
. The guard clause before the deprecation warning triggers unless ActsAsFollower.custom_parent_classes, and . . . ah, it looks like the issue is that this variable is initialized to [] instead of nil.

Okay, so the cleanest way here is simply by merging this PR. The second cleanest way is by changing the guard clause to say unless ActsAsFollower.custom_parent_classes.present? instead of just unless ActsAsFollower.custom_parent_classes.

@sambostock
Copy link

Is this going to be merged?

@JerryArns
Copy link

Please merge, my tests are ugly :)

Copy link

@beneggett beneggett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we merge this bad boy?

@kidbombay
Copy link

Yes can we merge?

@JerryArns
Copy link

Does anyone have contact with Tom?

@Gregdebrick
Copy link

Hey guys,
It's steel not working, and my logs render :

DEPRECATION WARNING: Setting custom parent classes is deprecated and will be removed in future versions. (called from parent_class_name at /Users/me/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/bundler/gems/acts_as_follower-c5ac7b9601c4/lib/acts_as_follower/follower_lib.rb:10)

@hiroro-work hiroro-work mentioned this pull request Sep 16, 2018
24 tasks
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

Successfully merging this pull request may close these issues.

7 participants