[英]ruby on rails undefined method(s) for active record
(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
耙db:migrate
command .. in the root folder of my rails project .. 命令..在我的rails项目的根文件夹中..
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 .. ! 注意:我也使用了整型和文本字段,但它不起作用..错误总是根据迁移文件中的类型更改为未定义的数据类型{string,integer,text,...}。 Note: I'm using the rake db:migrate in the root folder of the app.
注意:我在应用程序的根文件夹中使用rake db:migrate。
Check your version of rails. 检查您的rails版本。 This "t.string" syntax came to rails when the Sexy Migrations plugin was merged into the core.
当Sexy Migrations插件合并到核心中时,这种“ t.string”语法就出现了。 If you cannot upgrade to the latest version, you should use
如果无法升级到最新版本,则应使用
t.column :first_name, :string
syntax. 句法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.