开发者

ruby on rails undefined method(s) for active record

(in /Users/sayedgamal/apps/test)
/Users/sayedgamal/apps/test/config/boot.rb:20:开发者_StackOverflowWarning: 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜