Coder Social home page Coder Social logo

Comments (15)

fourfour avatar fourfour commented on June 14, 2024

I think I solved this: Pull request here:
#13

from groupify.

dwbutler avatar dwbutler commented on June 14, 2024

I believe this issue is caused by using the last stable version (0.5.1) which doesn't have group memberships implemented. Please double check and make sure you're using the release candidate (0.6.0.rc1).

from groupify.

fourfour avatar fourfour commented on June 14, 2024

Ya, I am on 0.6.0.rc1.

It is working by using self.id on this line:
member.group_memberships.where(group_id: self.id, membership_type: membership_type).first_or_create!

Now I am getting a no relation error using `user.groups'

from groupify.

dwbutler avatar dwbutler commented on June 14, 2024

I'll take a closer look at your Gist and see if any configuration is missing.

from groupify.

fourfour avatar fourfour commented on June 14, 2024

Thanks man, appreciate it. Love the gem, it's exactly what I need atm.

from groupify.

dwbutler avatar dwbutler commented on June 14, 2024

Great, hope we can figure this out! I'm trying to reproduce this locally. What version of ActiveRecord are you using?

from groupify.

fourfour avatar fourfour commented on June 14, 2024

4.0.5

from groupify.

fourfour avatar fourfour commented on June 14, 2024

You know what, it's working fine in my test app... But not in my real app. So it must be something in there. Strange, it's setup the same.

from groupify.

dwbutler avatar dwbutler commented on June 14, 2024

I forked your gist and modified it to make the code runnable: https://gist.github.com/dwbutler/e7d6aaa64cbaa792402b

It's working fine without any issues.

Is it possible you forgot to run the migrations? =)

from groupify.

fourfour avatar fourfour commented on June 14, 2024

ok I think I got it. I had already had a Group model setup before I started using Groupify, so there was a has_many :groups in User. Must have been confusing it.

I think everything is working now. Thanks a ton for you help 👍

from groupify.

dwbutler avatar dwbutler commented on June 14, 2024

You're welcome!

from groupify.

fourfour avatar fourfour commented on June 14, 2024

Spoke to soon. It worked for a second and then stopped.

https://gist.github.com/fourfour/91c72ea1c9fc8df8f708

It's like it's missing the has_many association

(Sorry to bug you about this)

from groupify.

dwbutler avatar dwbutler commented on June 14, 2024

I think the issue is with how you're using ActiveRecord. Try replacing:

u = User.where(:email => '[email protected]')

with:

u = User.where(:email => '[email protected]').first

Notice in your gist that without first, your query is returning ActiveRecord::Relation (which represents an array of results) rather than a single User object.

from groupify.

fourfour avatar fourfour commented on June 14, 2024

Interesting. I have never run into that before, but you are correct sir!

Thanks dude.

from groupify.

dwbutler avatar dwbutler commented on June 14, 2024

No problem!

from groupify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.