Hey, I need to use "longtext" as a data type in a migration. It works when I make create a table, like this: create_table :joes do |t| t.column :lots_o_content, :longtext end But if I try to add it to another table in a later migration, like this: add_column :sams, :lots_o_other_content, :longtext Then I get this error when trying to run the migration: -- add_column(:sams, :lots_o_other_content, :longtext) rake aborted! You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[] My question is, how can I add a column of type "longtext" in a migration? -- 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 06 Feb 2008, at 17:38, Joe Peck wrote:> Hey, I need to use "longtext" as a data type in a migration. > > It works when I make create a table, like this: > create_table :joes do |t| > t.column :lots_o_content, :longtext > end > > But if I try to add it to another table in a later migration, like > this: > add_column :sams, :lots_o_other_content, :longtext > > > Then I get this error when trying to run the migration: > -- add_column(:sams, :lots_o_other_content, :longtext) > rake aborted! > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.[] > My question is, how can I add a column of type "longtext" in a > migration?You can''t, as it isn''t one of the column types, use :text, which is what you want for a text blob: http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/ TableDefinition.html Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Never mind, I found out how to do it. I just put this in the migration instead of using "add_column": execute "ALTER TABLE sams ADD COLUMN lots_o_other_content LONGTEXT" -- 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 -~----------~----~----~----~------~----~------~--~---