Hi Everybody, I''m developing a little task management system with a Task model that belongs to Users and Projects. The problem is that sometimes a task won''t belongs to an user AND a project. It will be possible to add a task to a project without delegate it to any user. In a similar way, it will be possible for users to create a new task without assigning it to any project. So, my question is: Can I simply create the belongs_to associations for the Task model and leave the foreign_ids empty in the cases where the task doesn''t have an user or a project? Is there a better solution? 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 -~----------~----~----~----~------~----~------~--~---
Ivor Paul
2008-Dec-31 00:07 UTC
Re: Problem with associations that could be null sometimes
Yes, you can :) On Tue, Dec 30, 2008 at 4:49 AM, cassiozen <cassiozen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Everybody, > > I''m developing a little task management system with a Task model that > belongs to Users and Projects. > > The problem is that sometimes a task won''t belongs to an user AND a > project. It will be possible to add a task to a project without > delegate it to any user. In a similar way, it will be possible for > users to create a new task without assigning it to any project. > > So, my question is: Can I simply create the belongs_to associations > for the Task model and leave the foreign_ids empty in the cases where > the task doesn''t have an user or a project? Is there a better > solution? > > 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 -~----------~----~----~----~------~----~------~--~---