well...
I assume you''re using a MySQL DB; If that is the case you actually
need to specify specific options when connecting to the server to
allow multiple queries in one statement. I''ve honestly never played
with that before, but
http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html
should be a good start if you still want to go that route.
However, if your main concern is having a non-autoincrementing integer
as the primary key (which is perfectly legitimate), its not hard.
Write the migration is Ruby as normal, except also pass :id => false
to the create_table method. Then run a query to alter table to add the
primary key (you can also use this to add actual DB constraints and
foreign keys and what not, although if you do this alot you''re better
off finding/writing a plugin to do this in a more Rubylike way).
Finally in your model, use
set_primary_key :name_of_primary_key_field.
On May 1, 2:50 am, Marnen Laibow-Koser <rails-mailing-l...@andreas-
s.net> wrote:> Vipin wrote:
>
> [...]
>
> > because there is no other way i guess to have a non integer primary
> > key in Rails framework
> > --vipin
>
> Be careful! Rails *really* wants an integer primary key on most tables.
> Although it may be possible to do without it, I understand that problems
> may arise (Fred or other experts, can you confirm this?). My advice
> would be to let Rails put in the key that it wants. It won''t hurt
> anything.
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
> --
> Posted viahttp://www.ruby-forum.com/.