Rails db migration, undefined method `to_sym', can't figure out syntax

Maybe you are trying to do a migration like this:

class AddTestingMigratoToBlog < ActiveRecord::Migration  
  def change
    change_table :testing do |t|
      t.change :name, limit: 26
      t.change :last_name, limit: 26
      t.change :email, limit: 300
    end
  end
end

The error is because you were missing the type of the column.

Usage: change_column(table_name, column_name, type, options = {})

So this should work for you:

class AddTestingMigratoToBlog < ActiveRecord::Migration  
  def change
    change_table :testing do |t|
      t.change :name, :string, limit: 26
      t.change :last_name, :string, limit: 26
      t.change :email, :string, limit: 300
    end
  end
end

Victor Velazquez

Coder, Musician, Startups, Passionate Dancer & Life Lover. Software Engineer at MagmaLabs, Co-founder of Web Dev Talks, Co-founder of Voltaire, Co-founder of Paqkit, Ex-co-founder of Zaznova.

Subscribe to The zazvick's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!