Can a '':primary_key'' to store strings or has to be integers? t.primary_key :text_code --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
From a databases perspective, a string could easily be a primary key. What are you looking at acheiving, could you do it using validates_uniquness_of :xyz ? Cheers, James On Nov 6, 2007 9:34 PM, Kless <jonas.esp-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > Can a '':primary_key'' to store strings or has to be integers? > > t.primary_key :text_code > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
James Brooks ha escrito:> From a databases perspective, a string could easily be a primary key. What > are you looking at acheiving, could you do it using validates_uniquness_of > :xyz ?No, I need a string as primary key. I hope to have not any problem. Thanks> > Cheers, > James > > On Nov 6, 2007 9:34 PM, Kless <jonas.esp-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > Can a '':primary_key'' to store strings or has to be integers? > > > > t.primary_key :text_code > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Solved! Primary key for a string field of until 3 characters: create_table :cars, :id => false, :primary_key => :alpha_code do |t| t.string :alpha_code, :limit => 3 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In PSQL isn''t showed the primary key. I''m supposed that you have to exec the sql yourself to add the primary key constraint. Conclussion: it''s better don''t go against rails'' standard practices. On 6 nov, 12:53, Kless <jonas....-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Solved! > > Primary key for a string field of until 3 characters: > > create_table :cars, :id => false, :primary_key => :alpha_code do |t| > t.string :alpha_code, :limit => 3--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---