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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:38:27+00:00 2026-05-12T22:38:27+00:00

I am a Rails beginner and trying to understand how rails migration works. I

  • 0

I am a Rails beginner and trying to understand how rails migration works.
I have created a scaffold like:

script/generate scaffold Item col1:string col2:text
rake db:migrate

I would like to add another col4 using migration:

I created a migration as follows:

class AddCol4 < ActiveRecord::Migration
  def self.up
        add_column      :items, :col4, :numeric
        Item.reset_column_information
  end

  def self.down
        remove_column   :items, :col4
  end
end

When I run rake db:migrate the new column gets added. However the view is out of sync.
Am I supposed to manually add the new column to the view? Is there a way to auto-regenerate the model/view using the new table columns?

Sorry, it is a basic question but from my experience with other frameworks, it should have been automatic.
The rails guide on migration does not make this obvious regarding how the synchronization is supposed to work after you perform a migration.

  • 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-12T22:38:27+00:00Added an answer on May 12, 2026 at 10:38 pm

    Unfortunately you will need to modify the view manually. The view is created by running the script/generate scaffold command. Migrations only change the database. Technically, you can rerun the scaffold command and have it regenerate the view. It will ask you if you want to overwrite the previous file, however, if you go this route, you will still need to specify ALL of the columns that you want. You can’t simply add some here and there.

    If you are early in development, then you might take this route. Simply run

    script/destroy scaffold Item
    

    and then rerun

    script generate scaffold Item col1:string col2 string col3:numeric
    

    There are some dynamic scaffolding extensions available such as ActiveScaffold if you are creating something that only a few users will see, but I would recommend doing the HTML yourself as it will always come out the way you want.

    I can’t seem to find any of the other dynamic scaffolding plugins. There used to be quite a few…

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

Sidebar

Related Questions

I'm a rails beginner and have been several hours now trying to figure out
I'm a beginner at Ruby On Rails and am trying to get a migration
Hey all,(im a beginner in rails) i've created a controller that look like that:
I'm a complete rails beginner and I'm trying to understand the full concepts. I've
I am a beginner Ruby on Rails developer. So far I have created several
I'm a beginner programmer in Rails and I'm currently trying to create a simple
Rails beginner here.. I have a users resource where I implemented a callback that's
I am beginner in rails. I have view that i try to print inside
I am very much a beginner to rails and I have a specific need
I am beginner in ruby + rails. I have problem to get values in

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.