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

Simon
Tue, 01 Aug 2006 13:02:27 -0000

Chris wrote:
> So when you create a new activerecord instance (before you save it) does
> it look to see what the default value is from the schema?
>
> I want the default value to be assigned upon creation of the object,
> i.e. Record.new, and not when it gets saved.

Set the default value in the controller.

eg.
def firstpage
  Tablename.column = default_value
end

I havn''t looked at ruby for a while but its something like that.
Does this help?