Can someone give me an example of how to add devise to 2 different models with existing databases,i have 2 models, customer and vendor.If I just add :confirmable on both models and do the migration rails g migration add_confirmable_to_devise
will confirmable option be included in both models after I migrate the database?
Asked
Active
Viewed 161 times
2

KhoaVo
- 376
- 3
- 18
1 Answers
2
No you would have to create two separate migrations:
rails g migration 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 migration 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
That was just for Confirmable as that is the module you specified. If you wanted other devise modules (Trackable, DatabaseAuthenticatable etc) you would need to add those columns to the migration too.
You would also have to add the :confirmable (and any other features you wanted) to the models themselves.

RichardAE
- 2,945
- 1
- 17
- 20
-
hey thanks this helped me, can you tell me how can I trigger other mail send method to the customer table? Basically customisation Thank you. – Pavan Kumar V Feb 06 '23 at 09:31