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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:31:37+00:00 2026-05-14T18:31:37+00:00

I am trying to model a publications. A publication can have multiple authors and

  • 0

I am trying to model a publications. A publication can have multiple authors and editors. Since it is possible that one person is an author of one publication and an editor of another, no separate models for Authors and Editors:

class Publication < ActiveRecord::Base
  has_and_belongs_to_many :authors, :class_name=>'Person'
  has_and_belongs_to_many :editors, :class_name=>'Person'
end

The above code doesn’t work, because it uses the same join table. Now I now that I can specify the name of the join table, but there is a warning in the API documentation is a warning about that which I don’t understand:

:join_table:
Specify the name of the join table if the default based on lexical order
isn’t what you want. WARNING: If
you’re overwriting the table name of
either class, the table_name method
MUST be declared underneath any
has_and_belongs_to_many declaration in
order to work.

  • 1 1 Answer
  • 3 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-14T18:31:37+00:00Added an answer on May 14, 2026 at 6:31 pm

    It means that if class Publication is linked to a table with no standard name, example “my_publications”:

    class Publication < ActiveRecord::Base
      set_table_name "my_publication"
    end 
    

    The set table name should be put behind the habtm declaration for this to work:

    class Publication < ActiveRecord::Base
      has_and_belongs_to_many :authors, :class_name=>'Person'
      has_and_belongs_to_many :editors, :class_name=>'Person'
      set_table_name "my_publication"
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to model a network of Person s. A Person can have many
I'm trying to model a composite object that consists of one or more shapes.
basically I am trying to model some map brushes that have the following format:
I am trying to model the UX for search as follows: How can I
I am trying to model a network using C++. I have a struct called
For a medical website I'm trying to model a questionnaire that should result in
I'm structuring a database, and found that I have two different objects I'm trying
I'm trying to model which countries border each other in MySQL. I have three
I'm trying to model a certain process and I'm thinking that the State Pattern
I'm trying to model artists and songs and I have a problem where I

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.