1) while creating table (migration file) mention “id as false” as follows
class CreateRadusergroups < ActiveRecord::Migration
def change
create_table :radusergroups, :id => false do |t|
t.integer :priority
t.integer :image_id
t.string :username, :groupname
end
end
end
2) setting another primary key have two options
1) By Model class code
when you have table named images that contained a field named image_id. the code will be
class Image < ActiveRecord::Base
set_primary_key “image_id”
end
2) in migration file adding one more line as follows
class CreateRadusergroups < ActiveRecord::Migration
def change
create_table :radusergroups, :id => false do |t|
t.integer :priority
t.integer :image_id
t.string :username, :groupname
end
end
execute “ALTER TABLE radusergroups ADD primary key(image_id)”
end
Even though we have a different primary key field name. still we can refer it as “id”