I''m developing a messaging service for an application. It''s not an instant messaging, it''s more similar to how e-mail works. I send a message to user, user receives the message, I have a copy of the message sent by me in ''sent'' folder. That''s what the question is about. User gets the message from me and I have a copy of that message in ''sent'' folder. Where to store both of them? Do I need different tables within database - one for messages and another one for sent messages? Or it could be working well with one table? Do I really need to make a copy of message in order to make a sent message? Or it could be done without data redundancy, i.e. with one entry in one table per message? That''s not the question particularly about rails, but I''m not aware where to ask. Someone should have done something similar. Any advices? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''d define it like this: User model has_many :from_messages. :class_name => "Message", :foreign_key => "from_id" has_many :to_messages, :class_name => "Message", :foreign_key => "to_id" Message model: belongs_to :to, :class_name => "User", :foreign_key => "user_id" belongs_to :from, :class_name => "User", :foreign_key => "user_id" I think in Rails 2.0 you don''t need to specify the foreign keys for the belongs_to on messages because it''ll guess it from the class name. On Jan 11, 2008 9:50 AM, truetype <oleg.lyamin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m developing a messaging service for an application. It''s not an > instant messaging, it''s more similar to how e-mail works. I send a > message to user, user receives the message, I have a copy of the > message sent by me in ''sent'' folder. > > That''s what the question is about. User gets the message from me and I > have a copy of that message in ''sent'' folder. Where to store both of > them? Do I need different tables within database - one for messages > and another one for sent messages? Or it could be working well with > one table? Do I really need to make a copy of message in order to make > a sent message? Or it could be done without data redundancy, i.e. with > one entry in one table per message? > > That''s not the question particularly about rails, but I''m not aware > where to ask. Someone should have done something similar. Any advices? > > Thanks. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Also, to save you a lot of time. There are some GREAT messaging plugin''s that handle all the basic work and features up on the agilewebdevelopment site. http://agilewebdevelopment.com/plugins/search?search=messaging acts_as_messagable sounds like it''ll do what you want and more. Restful_easy_messages sounds good too. On Jan 10, 1:20 pm, truetype <oleg.lya...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m developing a messaging service for an application. It''s not an > instant messaging, it''s more similar to how e-mail works. I send a > message to user, user receives the message, I have a copy of the > message sent by me in ''sent'' folder. > > That''s what the question is about. User gets the message from me and I > have a copy of that message in ''sent'' folder. Where to store both of > them? Do I need different tables within database - one for messages > and another one for sent messages? Or it could be working well with > one table? Do I really need to make a copy of message in order to make > a sent message? Or it could be done without data redundancy, i.e. with > one entry in one table per message? > > That''s not the question particularly about rails, but I''m not aware > where to ask. Someone should have done something similar. Any advices? > > Thanks.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---