I have a Question which can have many statuses (Open, Closed, Expired,, etc) I have made a Question_Statuses Table to link to my Question Table. The model by default created by Rails makes the ID auto increment. I dun want the auto increment so i can change and delete statuses and have control of them as they link to my questions. I dunno if there is a better way to do this but i was thinking to have unique ID''s (no-increment) eg. 1-5 and give them names, and my questions have a status_id which points to a status. how would i go about implementing this in rails? and is there a better way to do it im missing ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Nov 17, 2007, at 9:04 PM, Chubbs wrote:> > I have a Question which can have many statuses (Open, Closed, > Expired,, etc) I have made a Question_Statuses Table to link to my > Question Table. The model by default created by Rails makes the ID > auto increment. I dun want the auto increment so i can change and > delete statuses and have control of them as they link to my questions. > > I dunno if there is a better way to do this but i was thinking to have > unique ID''s (no-increment) eg. 1-5 and give them names, and my > questions have a status_id which points to a status.What is the purpose of having a status table if they are simply constants? If you''re depending on the id being a particular value, then why not just omit the table and assign the status directly to the Question? On the other hand, if you plan on looking up the description of the status, then you can''t go around changing them and deleting them later. If you do, then your Questions will be pointing to either non- existent or incorrect states. If your needs are simple, just have a status String in the question and put the name of the state right in there. As in question.status = "open" If you are doing something complex, there''s an acts_as_state_machine plug-in. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
only reason why was having in separate table is so if i wanted to change the name or add descriptions to the status, or even change the order etc. If i was going to store the statuses in the Question table, how would i define in Rails the global variables for my statuses ? On Nov 18, 2:39 pm, George Bailey <listcatc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 17, 2007, at 9:04 PM, Chubbs wrote: > > > > > I have a Question which can have many statuses (Open, Closed, > > Expired,, etc) I have made a Question_Statuses Table to link to my > > Question Table. The model by default created by Rails makes the ID > > auto increment. I dun want the auto increment so i can change and > > delete statuses and have control of them as they link to my questions. > > > I dunno if there is a better way to do this but i was thinking to have > > unique ID''s (no-increment) eg. 1-5 and give them names, and my > > questions have a status_id which points to a status. > > What is the purpose of having a status table if they are simply > constants? > > If you''re depending on the id being a particular value, then why not > just omit the table and assign the status directly to the Question? > On the other hand, if you plan on looking up the description of the > status, then you can''t go around changing them and deleting them > later. If you do, then your Questions will be pointing to either non- > existent or incorrect states. > > If your needs are simple, just have a status String in the question > and put the name of the state right in there. As in > > question.status = "open" > > If you are doing something complex, there''s an acts_as_state_machine > plug-in.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Nov 17, 2007 9:39 PM, George Bailey <listcatcher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What is the purpose of having a status table if they are simply > constants?Normalization. Some DB types feel the DB should hold valid column values, since it may be accessed in multiple ways. --Michael --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---