small medium large xlarge

28 Aug 2008, 20:51
Martin Mooradian (4 posts)

I am having a little problem with a project that I am working on because I have two tables that need to be joined by a primary key, but the primary key is not an integer. I am trying to create a search engine for political contributions and the donations all have one “committee id” that is linked to a “committee”. The problem is that the every committee looks like this: C00001234 and in some cases H00VA987.

I tried to overide the process by appointing another column as my primary key, but when I do this, the column is coming up nil.

In theory I know this should be easy, but I think the problem is the that my primary key is not an integer.

Any suggestions?

29 Aug 2008, 14:12
Michael Mattingly (14 posts)

I’m no expert on the subject but this might help.

18 Sep 2008, 06:56
Mikhail V. Shokhirev (a.k.a. Mike Shock) (19 posts)

Martin! 1. If you decide which primary key to use, then do chhose a surrogate integer PK: it’ll save you much time in future. 2. Before appointing another column as the primary key, you needed to populate it by unique integer values (e.g. renumber the records). 3. If you work with a legacy DB, in which you can’t switch to another PK, it’s possible to use a non-numeric PK. But you’ll have to write a method for generating the keys to new records (def before_create; = generate_next_id; end).

22 Sep 2008, 18:51
Martin Mooradian (4 posts)


Thanks for the advice. I have put this down for a few weeks and will try it again with a fresh approach.



You must be logged in to comment