Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

登録画面ビュー

通常の登録画面で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を追記して解決

adonson
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away