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
Use base_class instead of superclass in parent_class_name #56
Conversation
Any news about this PR? i need it in my app :) |
Hi @bricesanchez I think the @Owners of this repository is not maintaining this repository, because I have seen lots of PR's pending into this repo and no one is replying on them. So if you want to use this functionality into your app you can add this https://github.com/brchristian/acts_as_follower/tree/patch-1 forked repository into your Gemfile. Example below
Thanks. |
@jcoyne any chance we could get this merged? Its necessary for Rails 5 compatibility. Thanks |
@mrjlynch Sorry, I'm no longer maintaining this as my employer has stopped using it. |
Is there a test for this behavior? Does it work under Rails 4 as well as Rails 5? |
@jcoyne In my opinion, #76 introduced a large amount of complexity which is actually not necessary, for either Rails 5-compatibility or for STI-compatibility. As discussed in #42, the My suggested PR here is based on the idea that supporting "custom parent classes" is not something acts_as_follower needs to do by default (I have a hard time thinking of a use case for this), and that I have rebased this branch on the current
Let me know if there’s anything else I can do to help out here, or any issues I’ve overlooked. Cheers! |
Hi @jcoyne, any chance we could get this merged? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a few issues about changing the public API without depreciations
yield @configuration if block_given? | ||
end | ||
|
||
def self.method_missing(method_name, *args, &block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not backward compatible. This method should be retained and a deprecation should be emitted
@@ -6,25 +6,5 @@ module ActsAsFollower | |||
autoload :FollowerLib, 'acts_as_follower/follower_lib' | |||
autoload :FollowScopes, 'acts_as_follower/follow_scopes' | |||
|
|||
def self.setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not backward compatible. This method should be retained and a deprecation should be emitted
@jcoyne Restored the custom_parent_classes functionality and added deprecation warnings. 👍 |
@jcoyne Anything else needed in this branch, or we good to merge? |
@brchristian thanks for the reminder. Good work. |
Welcome! Cheers! |
@johnmpotter I saw that you forked this PR branch of my repo. Now that it is merged, it looks like you can get back on to the |
@brchristian Awesome, that makes life easier, thanks for your work on this! 😃 |
Just to be clear, this PR now deprecates the use of Going forward, we should avoid using these methods? |
@jegodwin The deprecated behavior is simply the use of explicit custom "parent classes" via things like ActsAsFollower.custom_parent_classes = [CustomRecord] or ActsAsFollower.setup do |c|
c.custom_parent_classes = [CustomRecord]
end Your examples of |
@brchristian okay, got it. I was seeing the deprecation warning in the rails server logs whenever I called the Thanks for clarification. |
I was having a problem supporting polymorphic models in my application, and traced it back to this line.
If there are multiple levels of inheritance, this will go back one level -- but only exactly one.
For instance, let's say I have
When I follow a Fruit, it's stored in the db as
follower_type = "Fruit"
.When I follow a Fruit::Apple, it's also stored in the db as
follower_type = "Fruit"
.But, when I follow a Fruit, it's stored in the db as
follower_type = "Fruit::Apple"
. This causes all kinds of things to break in my app.Using
base_class
instead ofsuperclass
appears to give the intended behavior here.I believe this PR may also address the issues described in #8.
I believe this may also be a more general solution for the use of abstract classes than the one given in #42, as the docs for the
base_class
method say "Returns the class descending directly from ActiveRecord::Base, or an abstract class" (my emphasis). That said, I haven't looked into it more deeply than that.