0
私は次のような問題を抱えている:工夫、キュウリや複数のIDでログインするとき - 登録
私は私のサイト全体でのログインフォーム(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
を私がしたいですUSER_EMAIL
012:同じ属性-idを持つ私のページ上の2つのフィールドがあります -# 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")
しかし、今問題がある:私の登録フォームに必要事項を記入するキュウリとテスト
私は
# 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
で登録フォームに記入しようとすると、フィールドの属性-IDが同じで、「FILL_INは」間違った入力を選択...
にはどうすればIDを変更することができます念入りに働く?私のために複雑すぎると思われます..
私は正しく問題を指摘しましたか?
これは私のレンダリング登録サイトの一部である
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="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>
出力with_scopeを使用して問題を修正しましたデバッグparams'あなたの質問をよりよく理解するのに役立ちます。 – Zabba
私の記事を更新しました.. – Lichtamberg