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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:55:34+00:00 2026-05-26T21:55:34+00:00

I have an application which has projects and users . I don’t care about

  • 0

I have an application which has projects and users. I don’t care about tracking the many-to-many relationships between users and projects but I am interested in tracking the many-to-one relationship between projects and a specific user, which is the project manager. Ideally, I would like to create a column in the projects table called projectmanager_id and link it to a user. However, rails convention dictates that I use user_id instead. While this works, I feel the semantics aren’t quite right. Is there a way to have both?

One way I thought of is to create a projectmanagers table with user_id and project_id and have a has_many :projects, :through=> :projectmanagers in the user model, and has_one :user, :through => :projectmanagers in the project model. Is there a better way?

  • 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-26T21:55:34+00:00Added an answer on May 26, 2026 at 9:55 pm

    You could try this if you keep the db column as user_id:
    In your project.rb file:

    belongs_to :projectmanager, :foreign_key => “user_id”, :class_name => “User”

    And in your user.rb file still have:

    has_many :projects


    Or if it’s that you want your db column to be projectmanager_id

    In your project.rb file:

    belongs_to :projectmanager, :foreign_key => “projectmanager_id”, :class_name => “User”

    In your user.rb file:

    has_many :projects, :foreign_key => “projectmanager_id”, :class => “Project”

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

Sidebar

Related Questions

I have an application which has a Projects table and a Users table. In
I have an iphone application which has about 4 tabs. How do I force
I have a notes model, which has a many-to-many relationship with the users model.
I have a Rails project which has a Postgres database for the actual application
I have a Visual Studio Setup project which has a Application Folder DefaultLocation set
I have an application which has to live as a service, I create an
I have an application which has a similar interface to Visual Studio, in that
I have an AJAX application which has used CSS divs to create panels on
I have a Silverlight application which has on it a Canvas. On that Canvas,
I have an MVC application which has a set of fields for contact details

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.