How can I set default value for each column in a Database?


#1

I created a database in my rails project and want to set default value
for each column. I have read the self.up method of the file
db\migrate\20081123094926_create_bay_infos.rb and thought that this is
where I need to modify. But I don’t know how to do this.


#2

Zhao Yi wrote:

I created a database in my rails project and want to set default value
for each column. I have read the self.up method of the file
db\migrate\20081123094926_create_bay_infos.rb and thought that this is
where I need to modify. But I don’t know how to do this.

http://ar.rubyonrails.com/

Scroll down to “migrations”, click “learn more”

Search for :default to see some examples

Note that Rails questions are best asked on a Rails mailing list or
group. This list is focussed on the Ruby programming language, not Rails
(which is an application/framework written in Ruby)


#3

Brian C. wrote:

Zhao Yi wrote:

I created a database in my rails project and want to set default value
for each column. I have read the self.up method of the file
db\migrate\20081123094926_create_bay_infos.rb and thought that this is
where I need to modify. But I don’t know how to do this.

http://ar.rubyonrails.com/

Scroll down to “migrations”, click “learn more”

Search for :default to see some examples

Note that Rails questions are best asked on a Rails mailing list or
group. This list is focussed on the Ruby programming language, not Rails
(which is an application/framework written in Ruby)

Oh sorry for posting to a wrong forum. Thanks.