I am writing a private messaging system for my web app. Just think of it as doing the same thing as sending PMs on your typical social networking website like Facebook or Twitter, or even sending an e-mail through Hotmail.
I have come up with the following migration so far:
class CreateMessages < ActiveRecord::Migration
def self.up
create_table :messages do |t|
t.integer :sender_id, :recipient_id
t.string :title
t.text :body
t.boolean :read
t.timestamps
end
end
def self.down
drop_table :messages
end
end
However, the sender_id and recipient_id both refer to the same field, which is the id field in the Role model. What changes do I have to make so the interpreter knows it's referring to that field. Are there other changes I have to make such as join tables?