-
Notifications
You must be signed in to change notification settings - Fork 98
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
Getting NoMethodError undefined method 'accept!' for #<HasFriendship::Friendship:0x99c67b0> #25
Comments
I released a new version with #24. The tests were passing but there might have been some breaking changes. Please use the previous @ArmandoMendoza Could you help debugging this? Maybe people need a new migration because of this line? |
Should be fixed with 1.0.0. Can you try? |
Still getting it, unfortunately. Here's the full error message if it helps at all
|
Did you run the migrations? https://github.com/sungwoncho/has_friendship#upgrading-to-1xx |
Yeah, I did. |
Sorry to hear that. Please use 0.1.3 in the meantime. At the moment, I don't have enough time to investigate the issue. Could you help? also ping @Pensarfeo @ArmandoMendoza. Thanks. |
Yeah, of course. Also I get the same error when attempting to block friends (except it says undefined method block!, instead of accept!) |
So, after much digging I think I finally got it. First off, you can quick fix by simply adding :
to your Gemfile and then run the usual :
Now, regarding the cause of the issue, it seems to be coming from stateful_enum gem whose ActiveRecord extension is not properly required. Therefore, ActiveRecord's enum method is not overriden. Not sure how to fix this yet but I'll dig a bit more and I hope it helps. :) |
@eblohm, you can try @f-anthonioz's fix on v1.0.1. |
Yep, works great now! |
I'm honestly not sure why this is happening. Yesterday friendships could be accepted but now today they cannot. I haven't changed any code in the controller, and users can still request other users just fine, but now when a user tries to accept a request I get that error.
Here's my code in my controller for accepting friendships:
def accept
new_friend = User.find_by(username: params[:friend])
current_user.accept_request(new_friend)
flash[:notice] = "Successfully added #{new_friend.username}!"
redirect_to root_url
end
Like I said, this code was working fine yesterday, and I haven't touched anything related to friendships gem since it was working.
Edit: it looks like this might have something to do with the newest commit that was pushed yesterday, actually. Do I need to add more code now? Or run a new migration for something?
The text was updated successfully, but these errors were encountered: