diseño de rieles: agregar extras al registrarse

Hi I am using the devise gem for rails for app.

My question is after user creates the account I want him/her to create a profile as well. I want both to happen at the same time so I can do a 1-1 match with the user id and profile id.

¿Cómo puedo hacer esto?

¡Muchas gracias!

preguntado el 01 de febrero de 12 a las 22:02

1 Respuestas

Make it so the user modelo tiene un has_one relación con un profile model, and give the user model an after_create callback which creates a profile. What exactly are you confused about?

Respondido 02 Feb 12, 02:02

what if the user signs in but dont create a profile? That will destroy my model because I want to do a 1-1 with the ids. - SuperString

how do you give the user model a after_create call back? I think devise hides the model and controller implementations? - SuperString

Utilizar llamar de vuelta to make the profile creation happen behind the scenes. Did you want a custom sign up screen so they have to enter in attributes for the profile? I think Devise allows you to do that if you want. - Batkins

Yes I want to do that. However, how do I generate the controllers for devise classes? - SuperString

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.