【发布时间】:2016-09-16 00:10:39
【问题描述】:
我正在尝试在我的 Rails CRM 应用程序中存储一些潜在客户。这是示例 Lead 模型。
class Lead < ActiveRecord::Base
belongs_to :campaign
validates_presence_of :name
end
这是我用来将潜在客户存储在数据库中的示例迁移。
class CreateLeads < ActiveRecord::Migration
def change
create_table :leads do |t|
t.string :name, null: false, default: ""
t.string :contacts, null: false, array: true, default: []
t.string :emails, null: false, array: true, default: []
t.string :budget, null: false, default: "Not Specified"
t.string :requirements, null: false, array: true, default: []
t.timestamps null: false
end
end
end
我的潜在客户可能有多个电子邮件地址、联系电话和要求。因此,我决定将前面提到的列实现为数组。
我想确保没有任何潜在客户的电子邮件地址或联系人用于在数据库中创建新的潜在客户行。
我应该使用模型还是通过迁移来实现它?请指导我如何实现这种轨道方式。
【问题讨论】:
标签: ruby-on-rails-4 rails-activerecord rails-migrations rails-postgresql