I have a problem
I have a db with 2 tables
MAILS: id, receiver_id,sender_id,message
USERS: id, name
How i can do to link the attributes of models: receiver_id and sender_id with the id of the user's table?
For link i mean insert: belongs_to has_many...
If there aren't the 2 attributes but only receiver_id i can rename receiver_id like user_id and so i can set models like this:
class User < ActiveRecord::Base
has_many:mails
end
class Mail < ActiveRecord::Base
belongs_to:user
end





Bookmarks