LoginSignup
5
1

More than 3 years have passed since last update.

deviseのユーザー登録失敗後にビューがずれる。

Posted at

登録画面ビュー

通常の登録画面でapp/view/devise/registrations/new.html.hamlにCSSを当てたもの
スクリーンショット 2020-02-24 19.37.41.png

これにフォームに空などの無効な値を入れると以下のようになる。

登録失敗後のビュー

スクリーンショット 2020-02-24 19.38.43.png

//登録失敗時のnickname部分のHTML
<span class="nickname">
<div class="field_with_errors"><label for="user_nickname">ニックネーム</label></div>
<div class="field_with_errors"><input type="text" value="" name="user[nickname]" id="user_nickname"></div>
</span>

"field_with_errors"クラスが自動生成されてしまっていることが原因

registrations.scss
.field_with_errors {
  display: contents;
}

上記のCSSを追記して解決

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1