Comments on: Rails:join table name https://fromdelhi.com/2005/12/31/railsjoin-table-name/ Sun, 10 Jun 2007 16:37:22 +0000 hourly 1 https://wordpress.org/?v=5.3.21 By: Jeff https://fromdelhi.com/2005/12/31/railsjoin-table-name/#comment-34 Sun, 10 Jun 2007 16:37:22 +0000 http://www.fromdelhi.com/2005/12/31/railsjoin-table-name/#comment-34 so how does one specify a join table, where one of the tables being joined is itself a join table?

For example, I have a table of questions, and a table of answers. I have a join table called answers_questions. The answers_questions table tells me which answers are possible to which questions. However, I kept the primary key ‘id’ column here, because it’s more efficient for me when creating user records to have a single integer reference that tells me what question and what answer they gave.

So my join table has the id column, and now I want to create another table to join user id’s with the id’s of their question-answer pairs. What do I name this join table? First glance would seem to be “answers_questions_users”. Does rails support that?

And if not, what is the conventional Rails declaration to use such a setup?

Thanks!

]]>
By: jackie https://fromdelhi.com/2005/12/31/railsjoin-table-name/#comment-33 Thu, 22 Mar 2007 01:05:34 +0000 http://www.fromdelhi.com/2005/12/31/railsjoin-table-name/#comment-33 So you add one line of code. I don’t think it’s a big deal, and there doesn’t seem to be any other ripple-through effects. It’s unfortunate that they don’t mention it in the documentation that you have that option though. I don’t even remember what is… I think :join_table_name

Just remember that when you override table names, when you use AR, it still expects you to use your model name and plural of your model name.

]]>