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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:05:31+00:00 2026-05-21T15:05:31+00:00

I’m working on a new app in Rails 3 but I’m not sure how

  • 0

I’m working on a new app in Rails 3 but I’m not sure how can I build the relations between the models.

Basically I have a model User and a model Project. An user can create a Project, becoming the project owner. But any other user besides the project owner can join this project as well, but as team member.

Would I need to create a new model for this team relationship? And how would be the relations among this all?

Thanks in advance.

  • 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-21T15:05:32+00:00Added an answer on May 21, 2026 at 3:05 pm

    I’m doing something similar with a photo gallery that has shared permissions. Here is roughly the structure I’ve given it (though this is adapted from another project so may not be exactly right).

    class User
      has_many :projects, :foreign_key => "owner_id"
      has_many :project_memberships, :foreign_key => "member_id"
      has_many :shared_projects, :class_name => "Project", :through => :project_memberships, :foreign_key => "member_id"
    end
    
    class ProjectMembership
      belongs_to :member, :class_name => 'User'
      belongs_to :project
    end
    
    class Project
      belongs_to :owner, :class_name => "User"
      has_many :project_memberships
      has_many :members, :class_name => "User", :through => "project_memberships", :foreign_key => "member_id"
    end
    

    Basically, this allows a project to have both an owner that’s a user and a bunch of other members that are also users, and they can be accessed separately as such. These are related using a has_many :through relationship, and we’re basically giving a more meaningful name than what the default has_many :users would give us.

    This also gives individual members the ability to join a project by creating a new project_membership object for said project, while still maintaining a single owner.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.