Mohammed Niyas wrote in post #995052:> Hi All,
> I am trying to implement follow and unfollow functionality like in
> twitter in my application. I am new to mongodb and I am using mongoid in
> my rails 3 app. I dont know how to make a relation between my User model
> and friends model. And I am also maintaining a model named deals which
> contains the user_id as a forign key and I also want to display the
> latest deals post by user that have been followed by me. Anyone please
> guide me to implement this functionality.
> Thanks a lot in Advance....
All this is explained in the Mongoid documentation:
http://mongoid.org/docs/relations.html
MongoDB isn''t a relational database, which means there are differences
in how models are associated. First you need to decide which type of
association is best for a given relationship. Do you want the associated
objects to be "embedded" in the document, or do you want to store
references in the document.
http://mongoid.org/docs/relations/embedded.html
http://mongoid.org/docs/relations/referenced.html
Using embedded relations you can choose from one-to-many or one-to-one.
If you need many-to-many then you''ll need to use referenced.
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.