Rails relational table with multiple identifiers from one table

I know that if I name the column in the table "othertablename_id", then the rails will know whether to use this column for sort_to or another relation. If I want to have multiple identifiers from the same table, obviously this will not work, because I will have duplicate column names. What is the best way to create a table that joins two rows from one table? As in the table "Purpose", which applies to exactly two users.

+3
source share
2 answers

I have

belongs_to :user_1, :class_name => "User"
belongs_to :user_2, :class_name => "User"

user_1_id user_2_id . , , .

+6

:

Appointment 
=================
source_user_id
object_user_id

?

- 361, :

" "

... , . . .

alt text http://img180.imageshack.us/img180/4004/dibujolfa.png

Rails , has_and_belongs_to_many . , "HABTM." " " - "habtm."

-- . , . . , , category_products.

, , , , has_and_belongs_to_many.

+1

Source: https://habr.com/ru/post/1748611/


All Articles