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 8783023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:43:17+00:00 2026-06-13T20:43:17+00:00

I am developing a RoR application in which users can make Lists and invite

  • 0

I am developing a RoR application in which users can make Lists and invite other users to join their list(s). I am not sure how I should approach the invitation data model. I would assume that a user invitation model would be fairly common but I have not found any good examples.

I’d like any user to be able to invite any other user to their list. The invitee (an another user) would then be able to accept or reject the invitation.

I have a many-to-many relationship between users and lists currently. Should the join table between these two entities (lists_users) hold information concerning invitations? Would it be better to create another table, invitations, and add and remove records from it as users accept or reject invitations? If the latter is advisable how should I handle list owner (user) vs. list invitees (user)?

I’m grateful for any advice. Thanks!

Solution

I found it necessary to specify the table containing the foregin keys in User Model. ie

  has_many :owned_lists, :class_name => "List", :foreign_key =>"owner_id"
  has_many :created_invitations, :class_name => "Invitation", :foreign_key =>"invitor_id"
  has_many :received_invitations,:class_name => "Invitation", :foreign_key => "invitee_id"

-Nick

  • 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-06-13T20:43:18+00:00Added an answer on June 13, 2026 at 8:43 pm

    These are just my own two cents, but here’s how I’d do it.

    I’d keep one table lists_users to keep track of the users that have joined a list.

    I’d have a user_id column in the lists table to keep track of owners of lists.

    I’d then have a ’Invitation’ model with, for example, invitee_id, inviter_id and list_id, to keep track of invitations. An invitation is destroyed when it is used. Invitations probably also need some kind of active-until date.

    The models would look like this:

    class List < ActiveRecord::Base
      has_and_belongs_to_many :users
      belongs_to :owner, class_name: "User"
      has_and_belongs_to_many :invitations
    end
    
    class User < ActiveRecord::Base
      has_and_belongs_to_many :lists
      has_many :owned_lists, class_name: "List"
      has_many :created_invitations, foreign_key: "invitor_id"
      has_many :received_invitations, foreign_key: "invitee_id"
    end
    
    class Invitation < ActiveRecord::Base
      belongs_to :invitor, class: "User"
      belongs_to :invitee, class: "User"
      belongs_to :list
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Developing a demo application. Error: Can not resolve properties under push tag. name and
I am in the middle of developing an enterprise application using RoR (first time
I am developing a RoR application on two different machines. The iMac works fine,
I'm currently developing an API for my application on RoR As an example, I
I am developing a GWT application which im using Spring Security to handle the
I am developing RoR application that works with legacy database and uses ActiveScaffold plugin
Developing a .NET WinForms application: how can I check if the window is in
Developing a C# .NET 2.0 WinForm Application. Need the application to close and restart
Iam developing one application.In that iam placing the radio buttons(uiimageview) on table view and
While developing an application using gwt in ecliplse crashed. Now the server is running

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.