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 8700213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:07:48+00:00 2026-06-13T02:07:48+00:00

I am importing some data from an old Omnis 7 databse via a text

  • 0

I am importing some data from an old Omnis 7 databse via a text file into Rails. I am using text files for this purpose and am using db:seed to port it in.

In my seeds.rb file I have:

Port.delete_all
File.open("db_ports.txt", "r") do |ports|
  ports.read.each_line do |port|
    id, name, un_locode, bunker_surcharge, launch_tariff  = port.chomp.split("|")
    Port.create!(:id => id, :name => name, :un_locode => un_locode, :bunker_surcharge => bunker_surcharge, :launch_tariff => launch_tariff)
  end
end

I would like to have the ID number be the one as was assigned in the other database because Berths have a foreign key that looks to Ports and I would need those to match up with each other.

However, when I last imported my data, this didn’t work out as planned and the ID number was not passed in. I’m guessing that I could create empty records which I would then update with the data but was wondering whether this was possible.

  • 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-06-13T02:07:49+00:00Added an answer on June 13, 2026 at 2:07 am

    You won’t be able to set the id in the create! call because id is protected from mass assignment in this way. I believe you can set the id by doing something like:

    port = Port.new(:name => name, :un_locode => un_locode, ... )
    port.id = id
    port.save!
    

    You might want to consider having a separate attribute for the id in the old system though (old_omnis_id, maybe). I’ve seen this work successfully in the past. You can then use this attribute to join on in the association or, when you add the berths, you can look up the port’s id in the new system by the old id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some questions about importing data from Excel/CSV File into SQL Server. Let
I'm creating a PHP script that imports some data from text files into a
I am importing data from csv file, sometimes there are column headers and some
I am learning ruby on rails. I started by importing some data into a
I'm importing some images dynamically into a SWF from an external site using AS2.
I'm importing data from an excel file and I just noticed that some cells
I'm importing some data from a CSV into Mathematica. The first few lines of
I am importing data from a text file and have hit a snag. I
I'm importing data from youtube into a textarea using Javascript. If you I simply
I am importing data from a CSV file using fgetcsv(), which yields an array

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.