We are trying to use set_primary_key to cause an existing rails db to use a different primary key. This works find for accessing existing data, but gives an error when we try to add a new record, as it seems to still be accessing the record by the default id field at that point. Are there other changes we need to make to get an alternate primary key working? Thanks, Ken --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I have used the set_primary_key with some 3rd party propriety databases with no issues you describe. Could you give us some more information (table structure and such) to be able to help you adequately. On Dec 22, 10:51 pm, Kenneth McDonald <kenneth.m.mcdon...-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote:> We are trying to use set_primary_key to cause an existing rails db to > use a different primary key. This works find for accessing existing > data, but gives an error when we try to add a new record, as it seems > to still be accessing the record by the default id field at that > point. Are there other changes we need to make to get an alternate > primary key working? > > Thanks, > Ken--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think the problem is likely that the "old" primary key in the database is still the "id" field that rails generates and uses by default, and we can''t change that since (for the time being, our needs being modest) we''re using sqlite. We want to use a field called "rmr", basically an identification number, as the primary key, but this became obvious only after we''d created and started populating the database. Does Rails interrogate the database to find out which column is the primary key? Thanks, Ken On Dec 22, 2008, at 4:24 PM, Dejan Dimic wrote:> > I have used the set_primary_key with some 3rd party propriety > databases with no issues you describe. > > Could you give us some more information (table structure and such) to > be able to help you adequately. > > > On Dec 22, 10:51 pm, Kenneth McDonald > <kenneth.m.mcdon...-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote: >> We are trying to use set_primary_key to cause an existing rails db to >> use a different primary key. This works find for accessing existing >> data, but gives an error when we try to add a new record, as it seems >> to still be accessing the record by the default id field at that >> point. Are there other changes we need to make to get an alternate >> primary key working? >> >> Thanks, >> Ken > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think I read somewhere that when creating a new record you still have to reference the field as ''id'' (id=value) or it will not work. It''s worth the try. Pepe On Dec 22, 5:33 pm, Kenneth McDonald <kenneth.m.mcdon...-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote:> I think the problem is likely that the "old" primary key in the > database is still the "id" field that rails generates and uses by > default, and we can''t change that since (for the time being, our needs > being modest) we''re using sqlite. We want to use a field called "rmr", > basically an identification number, as the primary key, but this > became obvious only after we''d created and started populating the > database. > > Does Rails interrogate the database to find out which column is the > primary key? > > Thanks, > Ken > > On Dec 22, 2008, at 4:24 PM, Dejan Dimic wrote: > > > > > I have used the set_primary_key with some 3rd party propriety > > databases with no issues you describe. > > > Could you give us some more information (table structure and such) to > > be able to help you adequately. > > > On Dec 22, 10:51 pm, Kenneth McDonald > > <kenneth.m.mcdon...-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote: > >> We are trying to use set_primary_key to cause an existing rails db to > >> use a different primary key. This works find for accessing existing > >> data, but gives an error when we try to add a new record, as it seems > >> to still be accessing the record by the default id field at that > >> point. Are there other changes we need to make to get an alternate > >> primary key working? > > >> Thanks, > >> Ken--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- Problems with getting correct id from query involving two tables
- schema_info always wants to be 3, even when set to 7
- [ win32utils-Bugs-12979 ] Error while trying to update my gem collection
- could not find activerecord-sqlserver-adapter locally or in a repository
- set_primary_key issue