On Jan 6, 2010, at 4:51 PM, Quee WM wrote:

> I have an application in rails in which i am adding a new column in =
one
> of the tables. The value for the new column is a bit.ly link and I =
need
> to populate this for each record in the table approx. 250 rows will be
> affected.
>=20
> Q1: Can this be done outside the application? i.e. write a script that
> can interact with the db and then populate the appropriate column? And
> is this advisable?
>=20
> or
>=20
> Q2: if the aforementioned idea is not a good way then what will be the
> best way to update the existing records as any code i will write will
> only be used to update the table once.

Sure. If you use the "script/runner"-Script instead of the plain Ruby =
interpreter, your script will run in the fully loaded application =
environment. For one-shot scripts that are not exactly migrations, this =
is an acceptable way to do this. So:

  script/runner -e development path/to/my/script.rb

Regards,
Florian=