I have some question about RoR and MongoDB(use gem mongoid). For example I have two collection- users(fields: id, username, age) and messages(fields: id, message, user_to, user_from). I need to relate this collections. The model user-
....
has_many :messages
The model message-
....
belongs_to :to_user, :class_name => 'User', :foreign_key => 'user_to'
belongs_to :from_user, :class_name => 'User', :foreign_key => 'user_from'
Call in my view-
- @messages.each do |message|
%tr
%td
= message.message
%td
= message.to_user.username
%td
= message.from_user.username
But it not working. Please tell me how to relate it. B.R.