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

Getting NoMethodError undefined method 'accept!' for #<HasFriendship::Friendship:0x99c67b0> #25

Closed
eblohm opened this issue Apr 17, 2016 · 10 comments

Comments

@eblohm
Copy link
Contributor

eblohm commented Apr 17, 2016

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?

@sungwoncho
Copy link
Collaborator

sungwoncho commented Apr 17, 2016

I released a new version with #24. The tests were passing but there might have been some breaking changes. Please use the previous 0.1.3 while we look into it.

@ArmandoMendoza Could you help debugging this? Maybe people need a new migration because of this line?

@sungwoncho
Copy link
Collaborator

Should be fixed with 1.0.0. Can you try?

@eblohm
Copy link
Contributor Author

eblohm commented May 7, 2016

Still getting it, unfortunately. Here's the full error message if it helps at all

undefined method 'accept!' for #<HasFriendship::Friendship:0x007f999cf8d350>
Did you mean? accepted!

@sungwoncho
Copy link
Collaborator

@eblohm
Copy link
Contributor Author

eblohm commented May 7, 2016

Yeah, I did.

@sungwoncho
Copy link
Collaborator

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.

@eblohm
Copy link
Contributor Author

eblohm commented May 8, 2016

Yeah, of course. Also I get the same error when attempting to block friends (except it says undefined method block!, instead of accept!)

@f-anthonioz
Copy link
Contributor

So, after much digging I think I finally got it.

First off, you can quick fix by simply adding :

gem 'stateful_enum'

to your Gemfile and then run the usual :

bundle install

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. :)

@sungwoncho
Copy link
Collaborator

@eblohm, you can try @f-anthonioz's fix on v1.0.1.

@eblohm
Copy link
Contributor Author

eblohm commented May 14, 2016

Yep, works great 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

3 participants