У меня следующая проблема:
У меня есть форма входа на моем сайте (см. 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
Я хочу проверить с огурцом, чтобы заполнить мою регистрационную форму:
# 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")
Но теперь возникает проблема - на моей странице два поля с одинаковым атрибутом-идентификатором: user_email
Когда я пытаюсь заполнить регистрационную форму с помощью
# 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
идентификаторы полей одинаковы, а "fill_in" выбирает неправильный ввод ...
Как я мог изменить идентификаторы для работы с devise? Мне кажется слишком сложным ..
Правильно ли я указал на мою проблему?
UPDATE
Это часть моего зарегистрированного сайта регистрации:
<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="/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="/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>