不,您必须创建两个单独的迁移:
rails g 迁移 add_devise_fields_to_customer
class AddDeviseFieldsToCustomer < ActiveRecord::Migration
def change
# Confirmable columns
add_column :customers, :confirmation_token, :string
add_column :customers, :confirmed_at, :datetime
add_column :customers, :confirmation_sent_at, :datetime
add_column :customers, :unconfirmed_email, :string
end
end
rails g 迁移 add_devise_fields_to_vendor
class AddDeviseFieldsToVendor < ActiveRecord::Migration
def change
# Confirmable columns
add_column :vendors, :confirmation_token, :string
add_column :vendors, :confirmed_at, :datetime
add_column :vendors, :confirmation_sent_at, :datetime
add_column :vendors, :unconfirmed_email, :string
end
end
这只是为了可确认,因为那是您指定的模块。如果您想要其他设计模块(Trackable、DatabaseAuthenticatable 等),您也需要将这些列添加到迁移中。
您还必须将 :confirmable(以及您想要的任何其他功能)添加到模型本身。