I''ve just made a simple test app - it''s a very basic blog. I ran this (or something vaguely like this): ruby script/generate scaffold article title:string body:text id:primary_key Now, I''ve got the scaffold, but it shows an ID field. Is there any special shortcut for getting Rails to automatically fill in the primary key, or do I have to sort that out manually? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Never mind, I''m an idiot. Rails automatically gives objects a primary key. It''s always one step ahead of me; I need to catch up. -- 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-/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 Mar 1, 2008, at 1:45 PM, Peter Bunyan wrote:> Never mind, I''m an idiot. Rails automatically gives objects a primary > key.It won''t automatically create an index on it, though, so you might consider that. --~--~---------~--~----~------------~-------~--~----~ 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 01 Mar 2008, at 20:52, George Bailey wrote:>> Never mind, I''m an idiot. Rails automatically gives objects a primary >> key. > > It won''t automatically create an index on it, though, so you might > consider that.The primary key (in mysql at least, but i''d doubt it be otherwise in other dbms) is automatically indexed, that''s part of being a primary key. No need to put an index on it. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Peter De Berdt wrote:> On 01 Mar 2008, at 20:52, George Bailey wrote: > >>> Never mind, I''m an idiot. Rails automatically gives objects a primary >>> key. >> >> It won''t automatically create an index on it, though, so you might >> consider that. > > The primary key (in mysql at least, but i''d doubt it be otherwise in > other dbms) is automatically indexed, that''s part of being a primary > key. No need to put an index on it. > > > Best regards > > Peter De BerdtPostgreSQL and SQL Server (unless it''s changed recently) automatically index primary keys, but not foreign keys. In the PostgreSQL docs, I''m pretty sure it says that a primary key is enforced via a unique index. Peace, phillip -- 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-/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 -~----------~----~----~----~------~----~------~--~---