slava wrote in post #1064971:
I have *Messages* and *User* models with corresponding tables.
The *Messages* table has such fields like *user_from* and *user_to*.
I hope you mean your model names are "Message" and "User". Model names
should always be singular form. The underlying tables will be plural
How can associate the models to be able to access sender and recipient
You will need two foreign keys. You won't be able to rely solely on the
Rails naming conventions. Thankfully, the Rails defaults can be easily
Pay special attention to the options :class_name and :foreign_key. That
is how you override the Rails defaults and tell the model how to make