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

  • Home
  • SEARCH
  • 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 8476243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:07:34+00:00 2026-06-10T18:07:34+00:00

I loaded some seed data in using the code below, and it worked fine.

  • 0

I loaded some seed data in using the code below, and it worked fine. Then, I needed to add two more columns, and I did so using the following steps, but it’s not attaching the two new columns seed data to the table, what am I doing wrong?

Steps:

  1. Add two columns using migration
  2. Make them attr_accessible in the model
  3. Replace old CSV file with new CSV file
  4. Change the seed.rb file to plug in the new data
  5. Run rake db:seed

Seed.rb

require 'csv'

Model.delete_all
CSV.foreach("#{Rails.root}/lib/data/model.csv") do |row|
   Model.create!(:model_number => row[0], :areq => row[1], :length => row[2], :width => row[3], :depth => row[4], :material => row[5], :frame => row[6], :edge => row[7], :tubes => row[8], :tube_length => row[9])
end

Schema.rb

create_table "models", :force => true do |t|
  t.string   "model_number"
  t.float    "areq"
  t.float    "length"
  t.float    "width"
  t.float    "depth"
  t.string   "material"
  t.string   "frame"
  t.float    "edge"
  t.datetime "created_at",   :null => false
  t.datetime "updated_at",   :null => false
  t.float    "tubes"
  t.float    "tube_length"
end
  • 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-10T18:07:36+00:00Added an answer on June 10, 2026 at 6:07 pm

    Cant say this may work 100%

    Try Model.reset_column_information above the seed file once

    this should refresh the columns information in table.

    require 'csv'
    
    Model.reset_column_information
    
    Model.delete_all
    #......
    

    just a guess check if the proper model.csv is getting loaded and have column 8 and 9 means have in all 10 columns.

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

Sidebar

Related Questions

This code allows the form to load before the data is loaded but some
I loaded some content in a DIV with AJAX. Then, i loaded different content
The tree-view is loaded with some data from a DB. I want to filter
I have some data loaded as a np.ndarray and need to convert it to
Using jQuery 1.7 I'm having trouble binding a Click event to some dynamically loaded
I'm using GCD's dispatch_after method when my application is being loaded to perform some
I have some code the requires the application to be completely loaded and compiled
In a DIV I place some text/html code which get loaded from a database.
I have this code: Window w = // something w.Loaded += // some code
I am using seeds.rb to populate some State model reference data: State.create :name =>

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.