Je vais avoir le problème suivant:génie, concombre et ID lors de la connexion - enregistrement
J'ai un formulaire de connexion sur l'ensemble de mon site (voir https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app):
# application.html.haml
...
= form_tag new_user_session_path do
= text_field_tag 'user[email]'
= password_field_tag 'user[password]'
%button Login
Je veux test avec concombre pour remplir mon formulaire d'inscription:
# register#new.html.haml
= semantic_form_for resource, :url => registration_path(resource_name) do |f|
= f.inputs do
= f.input :email, :required => true
= f.input :password, :required => true
= f.input :password_confirmation, :required => true
= commit_button("Registrierung absenden")
Mais maintenant, il y a un problème - il y a deux champs sur ma page avec le même attribut id: user_email
Lorsque je tente de remplir le formulaire d'inscription avec
# registration_steps.rb
When /^I fill in registration data$/ do |param|
# this one selects the wrong form - loginform instead of registration form
fill_in("user_email", :with => "blabla")
end
l'attribut-ids des champs sont les mêmes et « fill_in » sélectionne la mauvaise entrée ...
Comment pourrais-je changer les ids travailler avec un concept? Semble trop complexe pour moi ..
Ai-je signalé correctement mon problème?
MISE À JOUR
Ceci est une partie de mon rendu site d'inscription:
<html>
....
<!-- you see that both forms contain fields with the same ids! -->
<!-- so when i test f.e. with fill_in("user_login", :with => "123")
then the wrong form will be filled out! -->
<form accept-charset="UTF-8" action="https://stackoverflow.com/users/sign_in" method="post">
<input id="user_login" name="user[login]" size="30" type="text" />
<input id="user_password" name="user[password]" size="30" type="password" />
<input type="submit" value="anmelden" name="commit">
</form>
...
<form accept-charset="UTF-8" action="https://stackoverflow.com/users/sign_in" method="post">
<input id="user_login" name="user[login]" size="30" type="text" />
<input id="user_password" name="user[password]" size="30" type="password" />
<input type="submit" value="anmelden" name="commit">
</form>
...
</html>
sortie de ' debug params' vous aidera à mieux comprendre votre question. – Zabba
Mis à jour mon message .. – Lichtamberg