Added columns do not show up in new action

I’m trying to write my first app in rails (no better way to learn than
to do). I did my first migration to create the initial table, which
worked fine. I generated the scaffold and added one new line item (a
workout) to the database no problem.

I then wanted to add some more fields to the database table, so I built
another migration…

class AddFields < ActiveRecord::Migration
def self.up
add_column :workouts, :weight, :text
add_column :workouts,:maxheart, :integer
add_column :workouts,:minheart, :integer
add_column :workouts,:avgheart, :integer
add_column :workouts,:timehour, :integer
add_column :workouts,:timemin, :integer
add_column :workouts,:timesec, :integer
end

def self.down
remove_column :workouts,:weight
remove_column :workouts,:maxheart
remove_column :workouts,:minheart
remove_column :workouts,:avgheart
remove_column :workouts,:timehour
remove_column :workouts,:timemin
remove_column :workouts,:timesec
end
end

and ran rake, which worked fine. But when I go to the ‘new’ action,
those fields do NOT show up. They are in fact in the database, because I
logged into mysql and looked, and they show up in the list view as empty
fields.

Am I missing a step to get them to show?

On Dec 18, 2007, at 10:36 AM, Tom D. wrote:

Am I missing a step to get them to show?

If you actually generated the scaffold with

script/generate scaffold …

then you will have to edit the files to include the new fields.
That’s actually the point of scaffolding…it’s just a place to get
started. Have a look in views/ to see which files you
will need to modify.

Peace,
Phillip

Phillip K. wrote:

On Dec 18, 2007, at 10:36 AM, Tom D. wrote:

Am I missing a step to get them to show?

If you actually generated the scaffold with

script/generate scaffold …

then you will have to edit the files to include the new fields.
That’s actually the point of scaffolding…it’s just a place to get
started. Have a look in views/ to see which files you
will need to modify.

Peace,
Phillip

Ah! Duh…gotcha. So if I were using dynamic scaffolding it would have
worked, but once I generated the actual files… makes sense. Thanks!