ruby on Rails 未定义活动记录方法
(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)
当我发出这个错误时,我收到了这个错误
rake 数据库:迁移
命令..在我的rails项目的根文件夹中..
migrate/001_create_people.rb 内容:
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
注意:我还使用了整数和文本字段,但它不起作用.. 错误总是更改为未定义的数据类型 {string, integer, text ,...} 基于迁移文件中输入的内容..! 注意:我在应用程序的根文件夹中使用 rake db:migrate 。
(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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您的 Rails 版本。当Sexy Migrations 插件合并到核心中时,这种“t.string”语法就出现在rails 中。如果无法升级到最新版本,则应使用
语法。
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
syntax.