How to create a new associated template in Rails

Asked

Viewed 60 times

0

Assuming I own the user Admin, the Admin has a login_user, as system_user, and this relationship is polymorphic, because other types of users also have login_user.

When creating the Admin, I must add the fields of login_user.

<%= form_for(@admin) do |f| %>
<%= f.fields_for :login_user do |login_user_fields|%>
<%= render partial: 'login_users/fields', locals:{f: login_user_fields, login_user: @admin.login_user, }%>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

The idea is that when created a new admin, also be created a login_user to the same, some idea of how to do it?

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.