Using column_names I can get a nice list of columns in a table, but is there any way to detect the column *type?* Like "string", "integer", "boolean", etc? -- 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 -~----------~----~----~----~------~----~------~--~---
On 10 Jan 2009, at 17:11, Taylor Strait <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Using column_names I can get a nice list of columns in a table, but is > there any way to detect the column *type?* Like "string", "integer", > "boolean", etc?The columns method returns an array of column objects, which among other things, has the name and type of the corresponding column. Fred> > -- > 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 wrote:> On 10 Jan 2009, at 17:11, Taylor Strait > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > > wrote: > >> >> Using column_names I can get a nice list of columns in a table, but is >> there any way to detect the column *type?* Like "string", "integer", >> "boolean", etc? > > The columns method returns an array of column objects, which among > other things, has the name and type of the corresponding column. > > FredIndeed. It returns the below for an id column. Thanks. #<ActiveRecord::ConnectionAdapters::SQLiteColumn:0x23736b8 @precision=nil, @primary=true, @default=nil, @limit=nil, @type=:integer, @null=false, @name="id", @scale=nil, @sql_type="INTEGER"> -- 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 -~----------~----~----~----~------~----~------~--~---