1
votes

I set it up as per the documentation (I think): https://github.com/dwbutler/groupify

But then in the console:

user=User.new

group=Group.new

group.add user

user.in_group?(group)

=> false

Returns false, instead of true.

Problem.

I don't get it. I've a few different things and no joy. I'm stuck.

My latest attempt is here: https://github.com/Yorkshireman/sebcoles/tree/setup3 (setup3 branch)

I have a previous attempt on the setup2 branch.

There is little difference between the two branches (the migrations and subsequent scheme.rb were SLIGHTLY different).

Help!

3
I am having the same problem: user.in_group?(group) => false instead of true . Have you found a solution yet ? - codigomonstruo
This is a while ago now, and I stopped using the groupify gem for my project, but I think I did get it working before I stopped using it, and I think it was actually because I was using 'group' and 'user' as the variable names (as in the above routine in the original post). - Yorkshireman
I was doing the same thing - codigomonstruo

3 Answers

3
votes

I am guessing you have to save the attributes of the group, ex: type, membership_type etc.. Also, I m guessing that the user has to be saved in the database. User.new does not save anything. Same as Group.new. User.create or User.save will help

2
votes

This is a while ago now, and I stopped using the groupify gem for my project, but I think I did get it working before I stopped using it, and I think it was actually because I was using 'group' and 'user' as the variable names (as in the above routine in the original post).

Try doing:

user1 = User.new
group1 = Group.new
group1.add user1
user1.in_group?(group1)

Should (hopefully) return true!

0
votes

Make sure user.rb model includes

#For Groupify Gem 
groupify :group_member 
groupify :named_group_member