Adding a column to a table

This is a real newbie question with what i’m sure will be a simple
answer…

If i add a column a table (in a development application), how do i
update my models to reflect this change?

Cheers,

Steve

Stephen B. wrote:

This is a real newbie question with what i’m sure will be a simple
answer…

If i add a column a table (in a development application), how do i
update my models to reflect this change?

Hi STeve,

You don’t actually have to update your models. If you look insde the
model code, you’ll see it’s empty :slight_smile:

You may have to update the views/forms etc that the scaffold
generated. Unfortunately there’s no way to ncrementally do this, you
just have to destroy, then re-generate the scaffold (or just add the
field by hand).

Alan

If there’s nothing special your model needs to do with the column, you
don’t have to do anything. In development mode, your application will be
magically aware of the new field instantly.

If there’s something your model needs to know about the field, like a
foreign-key relationship (belongs_to, has_many, etc.) or an
attr_accessor declaration or something like that, then you put that in
your model and you’re all set.

In production mode, when you make changes like this, you need to restart
the application, either by restrting the webserver or restarting any
FCGI processes, depending on your production environment.

Stephen B. wrote:

This is a real newbie question with what i’m sure will be a simple
answer…

If i add a column a table (in a development application), how do i
update my models to reflect this change?

Cheers,

Steve

On 4/26/06, Stephen B. [email protected] wrote:

This is a real newbie question with what i’m sure will be a simple answer…

If i add a column a table (in a development application), how do i
update my models to reflect this change?

Cheers,

Steve

It will happen automatically. Your models determine which attributes
they have from the database on their own.
In development mode, that will happen every time a page loads. In
production, you need to restart the app.

That’s embarrassingly simple :0)

Cheers,

Steve