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

Use base_class rather than superclass #88

Open
bufordtaylor opened this issue Jan 15, 2017 · 2 comments
Open

Use base_class rather than superclass #88

bufordtaylor opened this issue Jan 15, 2017 · 2 comments

Comments

@bufordtaylor
Copy link

I've had some issues with this gem after updating to rails 5.

Upon installation, the object.follow(thing) works fine the first time, but every time thereafter, it fails with:

TypeError: no implicit conversion of nil into String

It's because ApplicationRecord is the class that parent_class_name is returning. You can see by this query:

INSERT INTO "follows" ("followable_id", "followable_type", "follower_id", "follower_type", "created_at", "updated_at") VALUES (14829, 'ApplicationRecord', 1, 'User', '2017-01-15 09:49:16.098371', '2017-01-15 09:49:16.098371') RETURNING "id"

I've done all the recommended steps with the config and I was about to give up until I saw that you're using superclass, which doesn't always provide the right class in a rails environment:

class A < ActiveRecord::Base
end

class B < A
end

> A.superclass
=> ActiveRecord::Base
> B.superclass
=> A

> A.base_class
=> A
> B.base_class
=> A

I added this commit to my own forked branch and it now works as expected: bufordtaylor@43ad8ae

@jeremylynch
Copy link

This is a duplicate of #56

@brchristian
Copy link
Contributor

@bufordtaylor Now that #56 has been merged, are you still experiencing this issue?

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

3 participants