【发布时间】:2020-11-24 12:11:18
【问题描述】:
是否可以为作为数组的类创建属性?我尝试阅读this,但并没有从中得到太多。我想做这样的事情:
class CreateArches < ActiveRecord::Migration
def change
create_table :arches do |t|
t.string :name
t.array :thearray
t.timestamps
end
end
end
这样当我在 Arch 的一个实例上调用 .thearray 时,我会得到一个可以添加新元素的数组。
ruby-1.9.2-p290 :006 > arc = Arch.new
ruby-1.9.2-p290 :007 > arc.thearray
=> []
【问题讨论】:
标签: ruby database-design attributes migration ruby-on-rails-3.1