为什么我不能做这样的事情:
class CreateModels < ActiveRecord::Migration
def self.up
create_table :fruit do |t|
t.array :apples
end
end
end
是否有其他方法可以使数组(“苹果”)成为 Fruit 类实例的属性?
在 Rails 4 和使用 PostgreSQL 中,您实际上可以在数据库中使用数组类型:
移民:
class CreateSomething < ActiveRecord::Migration
def change
create_table :something do |t|
t.string :some_array, array: true, default: []
t.timestamps
end
end
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)