Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6659631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:03:22+00:00 2026-05-26T02:03:22+00:00

I want to build groups that users can join, The flow of steps and

  • 0

I want to build “groups” that users can join,
The flow of steps and things needed is in my head but the code to build this lacks some bit since I’m still learning rails. I would like to ask some advice on your ideas best practice of what would be needed to accomplish below:

  • You can create a group with a name ‘test’
  • You automatically join the group test, other users can join to
  • If want to see a list of the users joined my group ‘test’

Im thinking of creating a model sessions like
groups|name|
But then how could I store the multiple users that are in this session?
Should I make an array of the user_id’s for example and make an extra column like
groups|name|user_ids ?

What would be best practice and what rails (3) methods could I use to get a very rough version of the above functionality up and running ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:03:22+00:00Added an answer on May 26, 2026 at 2:03 am

    From what I understand this is a many to many relationship. So you would have 3 models :

    class User < AR
      has_many :memberships
      has_many :groups, :through => :memberships
    end
    
    class Membership < AR
      belongs_to :user
      belongs_to :group
    end
    
    class Group < AR
      has_many :memberships
      has_many :users, :through => :memberships
    end
    

    and to know what users belong to a group :

    @group = Group.find_by_name("test")
    @users_group = @group.users
    

    Update

    to ensure the user creating the group also belongs to it :

    # in group_controller.rb
    def create
      @group = Group.new(params[:group])
      @group.users << current_user
    
      if @group.save
        # ... etc
      end
    end
    

    of course the current_user should exist/be logged in with the usual before_filter (if I remember correctly its authenticate! with devise)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a collection that stores groups of users. A user can
I want build a sketch pad app on iPhone, I assume that this type
I want to build flash application that can detect the user eyes color and
I want to build a form_tag that will allow me to post a new
I want to build a python program that deletes all the photos from my
I want to build a basic Client-Server application, where my android smartphone can stream
I want to build an interface that has scrolling text inside a UITextView, and
I want to build a contact list in js, but there are so many
I want to build a django site where a certain group of trusted users
I am looking to create a site that will allow users to create groups

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.