[Rails] how do set default value for ActiveRecord fields?

Ashley Moran
Tue, 01 Aug 2006 11:46:21 -0000

On Aug 01, 2006, at 12:26 pm, Chris wrote:

> Everytime a new record object is created i.e. Record.new, i want
> certain
> fields to be the same.
>
> Any idea how to do this?
> Thanks
> Chris

Chris,

You want to set defaults in the database columns.  The easiest way to
do this is to build your database with Rails migrations: http://
wiki.rubyonrails.org/rails/pages/UnderstandingMigrations and
use :default => XXX in your column definitions.

Ashley