Hello Chris, may I try to help you?
I thing you need something like this:

class *Message* < ActiveRecord::Base

  belongs_to :sender, :class_name => 'User', :foreign_key =>
'sender_id'
  belongs_to :receiver, :class_name => 'User', :foreign_key =>
'receiver_id'

end

class *User* < ActiveRecord::Base (restful_authentication plugin)
  # Virtual attribute for the unencrypted password
  attr_accessor :password
  ...
  attr_accessible :login, :email, :password, :password_confirmation

  has_many :sent_messages, :class_name => 'Message' , :foreign_key =>
'sender_id'
  has_many :received_messages, :class_name => 'Message' , :foreign_key
=> 'receiver_id'
  ...
end

and then you can do this:
@inbox = current_user.received_messages.find_by_receiver_id(:user)

I'm dont test this, but it shold work)
Sorry for my english.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to