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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:08:48+00:00 2026-06-02T20:08:48+00:00

My question is more related to naming conventions than programmation I guess. Let’s assume

  • 0

My question is more related to naming conventions than programmation I guess.

Let’s assume an application where users can create new articles (so they are the owner of these articles) and where you can add article “editors”, who can only update the article content.

class User
  include Mongoid::Document
  has_many :articles # as owner of the articles
  has_and_belongs_to_many :articles # as editor of the articles
end

class Article
  include Mongoid::Document
  belongs_to :user
  has_and_belongs_to_many :editors, :class_name => 'User'
end

What I want to know is how I should call the articles association in my User model. I mean, an article has an author and editors, which seems strong naming conventions to me, but a user has articles he created and articles he is the editor. How would you call/name/declare the last 2 associations?

  • 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-02T20:08:50+00:00Added an answer on June 2, 2026 at 8:08 pm

    I would call them as :edited_articles, and :authored_articles or :owned_articles, or something similarly straightforward names. Just dont forget to add the :class_name and :foreign_key or :through qualifiers to them.

    Update:

    For has_and_belongs_to_many relation you need a connection table, which is by default, is named of the two joined table. E.g. articles_users in your case. In this table you will propably have two ids, user_id and article_id. This way rails connects your models automatically.

    has_and_belongs_to_many :editors, :class_name => 'User', :foreign_id => 'user_id'
    

    Of course if you call it editor_id in the join table then use that. And the opposite, on the user side should work too.

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

Sidebar

Related Questions

This is related to my previous question More than 1 Left joins in MSAccess
This question is more Python related than Django related. I want to test write
The question might be related more to math than to programming. I'll explain the
Here is (more or less) a related question: Delphi - Populate an imagelist with
This question is more UI/Design-ish than hard-core programming is. Background: I've been coding in
This question is more about guidance than actually solving my problem: I need to
This question is more a re-insurance than one directly about how to code. As
I don't know is this question more related to mathematics or programming and I'm
See this related question on more generic use of the Boost Random library. My
This will not be a programming question but more technology / platform related question.

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.