I have this registration form using the pow library:
<%= form_for @changeset, @action, [as: :user], fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<%= label f, :role, "Are you a Teacher or Student?" %>
<%= select f, :role, ["Student": "student", "Teacher": "teacher"] %>
<%= error_tag f, :role %>
<%= label f, Pow.Ecto.Schema.user_id_field(@changeset) %>
<%= text_input f, Pow.Ecto.Schema.user_id_field(@changeset) %>
<%= error_tag f, Pow.Ecto.Schema.user_id_field(@changeset) %>
<%= label f, :first_name %>
<%= text_input f, :first_name %>
<%= error_tag f, :first_name %>
<%= label f, :last_name %>
<%= text_input f, :last_name %>
<%= error_tag f, :last_name %>
<%= label f, :password %>
<%= password_input f, :password %>
<%= error_tag f, :password %>
<%= label f, :password_confirmation %>
<%= password_input f, :password_confirmation %>
<%= error_tag f, :password_confirmation %>
<div>
<%= submit "Register" %>
</div>
<% end %>
When registration is successful, a user is added to the “users” table. However, I would like to make a function call upon successful registration which would also populate the user in either my “students” table or “teachers” table depending on their role. How would I be able to do this?