Bonjour a tous,
Je créer actuellement une petite appli (RAILS 3)
J'utilise le plugin d'authentification "devise", qui me permet de
gagner un temps précieux sur cette partie difficile.
Pour la suite, j'ai besoin d'associer au modèle "User" , le modèle
"Profile", afin que chaque utilisateur puisse avoir leur profile.
-----------
class Profile < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :http_authenticatable, :token_authenticatable, :lockable, :timeoutable
and :activatable
devise :registerable, :authenticatable, :confirmable, :recoverable,
:rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation
has_one :profile
accepts_nested_attributes_for :profile, :allow_destroy => true
end
-----------
Afin de faciliter tout ca, j'aimerais qu'a la création d'un compte
user, un profile soit créer aussi.
Des lors j'ai décider d'utiliser nested attribute :
-------
accepts_nested_attributes_for :profile, :allow_destroy => true
-------
Cependant, je n'ai pas accès au contrôleur gérant la création des
compte afin d'y inclure "user.profile.build"
Suis je en train de faire une erreur?
Nested attribute me permettent il de créer un profile automatiquement
a la création d'un compte ?
Merci d'avance,
--
Vous avez reçu ce message, car vous êtes abonné au groupe "Railsfrance" de
Google Groups.
Pour transmettre des messages à ce groupe, envoyez un e-mail à l'adresse
railsfrance@googlegroups.com
Pour résilier votre abonnement envoyez un e-mail à l'adresse
railsfrance-unsubscribe@googlegroups.com
To unsubscribe from this group, send email to
railsfrance+unsubscribegooglegroups.com or reply to this email with the
words "REMOVE ME" as the subject.
on 2010-03-24 18:04
on 2010-03-24 18:07
Le 24/03/10 18:03, nelson a écrit : > ----------- > :rememberable, :trackable, :validatable > > a la création d'un compte ? Devise n'a aucun controller concernant la création d'un compte. Donc je vois pas pourquoi tu n'as pas accès au controller user. Car justement il n'existe pas de base. -- Cyril Mougel http://blog.shingara.fr -- Vous avez reçu ce message, car vous êtes abonné au groupe "Railsfrance" de Google Groups. Pour transmettre des messages à ce groupe, envoyez un e-mail à l'adresse railsfrance@googlegroups.com Pour résilier votre abonnement envoyez un e-mail à l'adresse railsfrance-unsubscribe@googlegroups.com To unsubscribe from this group, send email to railsfrance+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
on 2010-03-24 18:08
bonjour, ajoute :profile_attributes à ton attr_accessible. Le 24 mars 2010 18:03, nelson <tugal94@hotmail.com> a écrit : > ----------- > :rememberable, :trackable, :validatable > > a la création d'un compte ? > > To unsubscribe from this group, send email to railsfrance+ > unsubscribegooglegroups.com or reply to this email with the words "REMOVE > ME" as the subject. > -- Vous avez reçu ce message, car vous êtes abonné au groupe "Railsfrance" de Google Groups. Pour transmettre des messages à ce groupe, envoyez un e-mail à l'adresse railsfrance@googlegroups.com Pour résilier votre abonnement envoyez un e-mail à l'adresse railsfrance-unsubscribe@googlegroups.com To unsubscribe from this group, send email to railsfrance+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
on 2010-03-24 18:36
Merci pour ces réponses rapides. @Cyril Mougel En tout cas, je n'ai crée aucun controller qui éventuellement gérerais la création du compte, des lors j'en déduis que c'est le plugin qui le gère lui même @Emilien Taque J'ai tenté d'ajouté : attr_accessible :email, :password, :password_confirmation, :profile_attributes Cependant, je en voit pas de modifications. Que devrais t il se passer normalement, un profile devrait se créer automatiquement a la création d'un compte user ? Ou bien, initialement rien n'est crée, et il faut utiliser dans les formulaires " f.fields_for :profile do |p| " afin de créer ce fameux profile. Merci -- Vous avez reçu ce message, car vous êtes abonné au groupe "Railsfrance" de Google Groups. Pour transmettre des messages à ce groupe, envoyez un e-mail à l'adresse railsfrance@googlegroups.com Pour résilier votre abonnement envoyez un e-mail à l'adresse railsfrance-unsubscribe@googlegroups.com To unsubscribe from this group, send email to railsfrance+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
on 2010-03-24 19:04
Oui, il faut soit f.fields_for :attribute dans ton formulaire, soit que tu crées le profile dans ton contrôleur, ou que mieux, tu t'en assures via un callback dans ton modèle, de ce genre : before_create do |user| user.profile ||= Profile.new end Le 24 mars 2010 18:35, nelson <tugal94@hotmail.com> a écrit : > attr_accessible :email, :password, :password_confirmation, > > ME" as the subject. > -- Vous avez reçu ce message, car vous êtes abonné au groupe "Railsfrance" de Google Groups. Pour transmettre des messages à ce groupe, envoyez un e-mail à l'adresse railsfrance@googlegroups.com Pour résilier votre abonnement envoyez un e-mail à l'adresse railsfrance-unsubscribe@googlegroups.com To unsubscribe from this group, send email to railsfrance+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.