How to create a new associated template in rails

0
Assuming I have the Admin user, Admin has login_user , as system_user , this relation is polymorphic, since other types of users also have login_user .

When creating the Admin form, I should 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 creating a new admin , a login_user is also created for it, any idea how to do it?

    
asked by anonymous 21.01.2015 / 00:38

1 answer

0

From what I saw, I think you did not instantiate the object in fields_for.

I suggest you read the method documentation: link

It explains what to do in the template to accept attributes from another template and save (accepts_nested_attributes_for).

    
06.03.2015 / 01:05