Mailbox model

Hi everyone,

I ran into some problems when modeling mailbox and mails. My code was

create_table :mailbox do |t|
t.integer :user_id # the owner of this mailbox

create_table :mails do |t|
t.integer :sender_id
t.integer :receiver_id
t.string :title
t.text :content

class Mailbox < ActiveRecord::Base
belongs_to :user

has_many :sent_mails,
:class_name => ‘mail’,
:conditions => { :sender_id => self.user_id } # I know this
is wrong

has_many :recv_mails,
:class_name => ‘mail’,
:conditions => { :receiver_id => self.user_id }

I know this is wrong. because user_id is an instance method and self
refers to the class object. My question is how to fix this problem?

Thanks in advance

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs