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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:27:40+00:00 2026-05-13T15:27:40+00:00

An old one of my ruby on rails migrations contains both the actual migration

  • 0

An old one of my ruby on rails migrations contains both the actual migration but also an action to modify data:

class AddTypeFlagToGroup < ActiveRecord::Migration
  def self.up
    add_column :groups, :selection_type, :string

    Group.reset_column_information
    Group.transaction do
    Group.all.each do |group|
      group.selection_type = group.calculate_selection_type
      group.save
    end
  end
  end

  def self.down
    remove_column :groups, :selection_type
  end
end

In this migration there are the usual add_column and remove_column migration statements. But there are also some model specific method calls.

I wrote this a couple of weeks ago. Since then, I have removed my Group model, which gives an error when I do a full migration with :reset.

rake db:migrate:reset
(in /Users/jesper/src/pet_project)

[...]

==  AddTypeFlagToGroup: migrating =============================================
-- add_column(:groups, :selection_type, :string)
   -> 0.0012s
rake aborted!
An error has occurred, this and all later migrations canceled:

uninitialized constant AddTypeFlagToGroup::Group

The thing is that in the current revision of my code, Group does not exist. How should I handle this “the rails way”??

I am thinking I could modify the migration by commenting out the Group.xxx stuff, but is this a wise way to go?

  • 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-13T15:27:40+00:00Added an answer on May 13, 2026 at 3:27 pm

    There is no value in leaving the group stuff in your migration now that it is gone from your project. I’d just edit the migration, drop everything from the db and migrate from scratch. There isn’t even a reason to comment it out (you are using version control right?)

    Also, I believe the “rails way” with migrations is spelled “Arrrrgh!”

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

Sidebar

Related Questions

I'm enjoying Ruby on Rails but one thing that seems overwhelming is the shear
I updated my python interpreter, but I think the old one is still called.
I got ruby 1.8.7 (native compiled), rails 2.3.4, OSX 10.6.2 and also sqlite3-ruby. The
Database migrations are a popular pattern, particularly with Ruby on Rails. Since migrations specify
I'm completely new to Ruby on Rails, have never worked on it, but I
While working with old app using rails 2.0.2 with ruby 1.8.6, getting following problem...
I'm starting to get comfortable with Ruby/Rails but must admit I still look askance
I got a new mac since the old one crashed and was trying to
I need to port one of my old program to Windows. The current version
I'm going back through one of my old apps (my first, actually), and am

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.