The form doesn't show the Pessoa's field, what's wrong?
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<h4>Usuário</h4>
<%= f.email_field :email, autofocus: true %>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
<%= f.password_field :password_confirmation, autocomplete: "off" %>
<h4>Pessoa</h4>
<%= f.fields_for :pessoa do |p| %>
<%= p.text_field :nome %>
<% end %>
<div class="actions">
<%= f.submit "Cadastrar" %>
</div>
<% end %>
I just see, email, password and password confirmation... class User:
class Usuario < ActiveRecord::Base
has_one :pessoa
has_many :pedidos, through: :pessoa
accepts_nested_attributes_for :pessoa
And RegistrationController:
class Usuarios::RegistrationsController < Devise::RegistrationsController
def new
build_resource(sign_up_params)
self.resource.pessoa = Pessoa.new
respond_with self.resource
end
def create
super
end
private
def sign_up_params
params.require(:user).permit(pessoas_attributes: [:nome])
end
end
Pessoa belongs to Usuario, ok? And need show email, password, password confirmation and name. When submit need save in two tables (Usuarios and Pessoas) the values registered. What I'm wrong? Thanks!
EDIT
The form Pessoa show, but after I filled out the data, dont save in DB, why? I did what I was asked to do. The user values save ok, but pessoas dont.
sign_up_paramsmethod.pessoas_attributesshould bepessoa_attributessince it ishas_onenothas_many. Also check the params key when submitting the form, it could beusuario.rake routes