Forum: Ruby on Rails Migrations

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9b08e89cdce5a02bc9c2222825a14a67?d=identicon&s=25 kai (Guest)
on 2007-04-02 08:28
(Received via mailing list)
Hi there

I would like to get some advice on migrations. New on Rails, I do no
exactly understand what is going on here.

I have created a table "tax" sucessfully using this code in a
migration file:

class CreateTax < ActiveRecord::Migration
  def self.up
    create_table :tax do |t|
      t.column(:rate, :integer, :default => 0)
      # more

  def self.down
    drop_table :tax

Later, in a second step, I tried to populate this table with test data
using this code:

class TestTax < ActiveRecord::Migration
  def self.up

    tax = Tax.create(
          :rate => 0,
          :description => '(none}',
          is_default => 0)!
    # more records...


  def self.down

This leads to "uninitialized constant TestTax::Tax" printed by rake.

Originally, I tried to follow the standard Rail conventions about
using plurals, but this did not work either. Only when I got an error
message about "Taxis" (??) I thought, well, plurals seems to cause
problems instead of being really helpfull, so I added:

 Inflector.inflections do |inflect|
    inflect.uncountable %w( tax )

to environment.rb

What do I miss here?

I have other problems with migrations which let me think that I do not
really understand what is going on.
For example, I have the impression that the name of a migration is in
some respect taken into account. (I am not talking about the "xxx_"
part of course).

I tried to find my way but only got the impression of inconsistency.

Is there a good source of information of how rails Rails is really
managing Migrations, with all rules/assumptions?

Thanks for help in advance!

This topic is locked and can not be replied to.