views:

376

answers:

2
(in /Users/sayedgamal/apps/test)
/Users/sayedgamal/apps/test/config/boot.rb:20:Warning: Gem::SourceIndex#search support for String patterns is deprecated
== CreatePeople: migrating ====================================================
-- create_table(:people)
rake aborted!
undefined method `string' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x238e97c>

(See full trace by running task with --trace)

I get that error when I'm issuing the

rake db:migrate

command .. in the root folder of my rails project ..

migrate/001_create_people.rb contents :
class CreatePeople < ActiveRecord::Migration
  def self.up
    create_table :people do |t|
     t.string :first_name
     t.string :second_name
     t.string :company
     t.string :email
     t.string :phone
    end
  end

  def self.down
    drop_table :people
  end
end

Note: that I also used the integer and text fields and it didn't work .. Error always changes to undefined datatype {string, integer, text ,...} based on the typed in the migration file .. ! Note: I'm using the rake db:migrate in the root folder of the app.

+2  A: 

Check your version of rails. This "t.string" syntax came to rails when the Sexy Migrations plugin was merged into the core. If you cannot upgrade to the latest version, you should use

t.column :first_name, :string

syntax.

neutrino
It definitely is, look at the migration number. I think both the idioms were changed at the same time.
Swanand
A: 

Thanks It's solved using the old syntax ..

eGaMaL