Forum: Ruby on Rails How can I set default value for each column in a Database?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7fbd0e99b27064b14793f028022974e5?d=identicon&s=25 Zhao Yi (youhaodeyi)
on 2008-11-23 12:11
I know I can set it on add_column command but I am looking for a way to
set the default when creating the Table. See below code, how can I set
each of them a default value.

def self.up
    create_table :bay_infos, :primary_key => :IP do |t|
      t.string :HostName
      t.string :IP
      t.string :Description
      t.string :user_name
      t.string :password

      t.timestamps
    end
  end
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-23 12:42
(Received via mailing list)
On Nov 23, 11:11 am, Zhao Yi <rails-mailing-l...@andreas-s.net> wrote:
> I know I can set it on add_column command but I am looking for a way to
> set the default when creating the Table. See below code, how can I set
> each of them a default value.
>
http://api.rubyonrails.com/classes/ActiveRecord/Co...

Fred
This topic is locked and can not be replied to.