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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Nov-23 11:41 UTC
Re: How can I set default value for each column in a Database?
On Nov 23, 11:11 am, Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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/ConnectionAdapters/TableDefinition.html#M001735 Fred> 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 > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---