I have the following problem, but first I will make some assumptions
- The example is just to explain my problem in an easy way
- The tables models are not related
I have two tables (models) Users an Emails
Users
- id
- name
Emails
- id
- account
So, the idea is every time I create a user, I want to create an instance of Email, where Emails.account = Users.email
I tried using callback
def after_create
Email.create!(:account => user.email)
end
But it didn't work.
Is there another way to achieve this?