Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4258134
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:36:31+00:00 2026-05-21T05:36:31+00:00

We have some imported data from a 3rd party which provides non-integer unique ids.

  • 0

We have some imported data from a 3rd party which provides non-integer unique ids.

In Rails 2.2.2 we were able to use :foreign_key on our has_many relationships with a non-integer column and it worked.

But we are now upgrading to Rails 2.3.8 and it seems to force the foreign_key to an integer. Has anyone found a way to get this working?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:36:31+00:00Added an answer on May 21, 2026 at 5:36 am

    According to this answer, the procedure has to be completed using execute:

    create_table :employees, {:id => false} do |t|
      t.string :emp_id
      t.string :first_name
      t.string :last_name
    end
    execute "ALTER TABLE employees ADD PRIMARY KEY (emp_id);"
    

    And as Sean McCleary mentioned, your ActiveRecord model should set the primary key using set_primary_key:

    class Employee < ActiveRecord::Base
      set_primary_key :emp_id
      ...
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data that has been imported from elsewhere. the sheet as you
I have given some data in an excel sheet to a 3rd party for
I've imported some data from a CSV file in matlab. They are time series
I have some dirty input data that is being imported into a raw source
I have imported data relating to about 70 human subjects from three data tables
I have an application that is scheduled and get some data from a another
I have an MS SQL Server 2008 Database, from which I am fetching data
I have some data loaded as a np.ndarray and need to convert it to
I have some arbitrary pixel data that I want to save as a PNG.
I have created two wsdl files with shared types imported from xsd schema file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.