前提・実現したいこと
新規登録をしたい
発生している問題・エラーメッセージ
ターミナルにはROLLBACKが出てくる
エラーメッセージ Started POST "/users" for ::1 at 2020-11-24 14:01:33 +0900 Processing by Devise::RegistrationsController#create as HTML Parameters: {"authenticity_token"=>"7NS6bhHq/tRHNV89oiL1xBVXrFqtrj+lKzfdgA0IfRs99Ghi6ftQMWwUIfigs7JBJO0h9h4UMMRySbdXSBx6KQ==", "user"=>{"email"=>"a@a", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "name"=>"a", "profile"=>"a", "occupation"=>"a", "position"=>"a"}, "commit"=>"新規登録"} (0.2ms) BEGIN User Exists? (0.3ms) SELECT 1 AS one FROM `users` WHERE `users`.`email` = BINARY 'a@a' LIMIT 1 (0.1ms) ROLLBACK Rendering devise/registrations/new.html.erb within layouts/application Rendered devise/registrations/new.html.erb within layouts/application (Duration: 1.8ms | Allocations: 1233) [Webpacker] Everything's up-to-date. Nothing to do Completed 200 OK in 265ms (Views: 35.8ms | ActiveRecord: 0.7ms | Allocations: 20266)
該当のソースコード
ruby
1(new.html.erb) 2<div class="main"> 3 <div class="inner"> 4 <div class="form__wrapper"> 5 <h2 class="page-heading">ユーザー新規登録</h2> 6 7 <%# 「モデル名」にはUserモデルであれば@userを渡しましょう。%> 8 <%# 「新規登録機能へのパス」は、devise導入後にrails routesを実行してdevise/registrations#createへのパスを確認し、記載してください。 %> 9 <%= form_with model: @user, url: user_registration_path ,id: 'new_user', class: 'new_user', local: true do |f| %> 10 11 <div class="field"> 12 <%= f.label :email, "メールアドレス" %><br /> 13 <%= f.email_field :email, autofocus: true, autocomplete: "email" %> 14 </div> 15 16 <div class="field"> 17 <%= f.label :password, "パスワード(6文字以上)" %><br /> 18 <%= f.password_field :password, autocomplete: "new-password" %> 19 </div> 20 21 <div class="field"> 22 <%= f.label :password_confirmation, "パスワード再入力" %><br /> 23 <%= f.password_field :password_confirmation, autocomplete: "new-password" %> 24 </div> 25 26 <div class="field"> 27 <%= f.label :name, "ユーザー名" %><br /> 28 <%= f.text_field :name %> 29 </div> 30 31 <div class="field"> 32 <%= f.label :profile, "プロフィール" %><br /> 33 <%= f.text_area :profile, class: :form__text %> 34 </div> 35 36 <div class="field"> 37 <%= f.label :occupation, "所属" %><br /> 38 <%= f.text_area :occupation, class: :form__text %> 39 </div> 40 41 <div class="field"> 42 <%= f.label :position, "役職" %><br /> 43 <%= f.text_area :position, class: :form__text %> 44 </div> 45 46 <div class="actions"> 47 <%= f.submit "新規登録", class: :form__btn %> 48 </div> 49 <% end %> 50 </div> 51 </div> 52</div>
ruby
1(user.rb) 2class User < ApplicationRecord 3 # Include default devise modules. Others available are: 4 # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable 5 devise :database_authenticatable, :registerable, 6 :recoverable, :rememberable, :validatable 7 has_many :prototype 8 9 validates :name, presence: true 10 validates :profile, presence: true 11 validates :occupation, presence: true 12 validates :position, presence: true 13end
ruby
1routes.rb 2Rails.application.routes.draw do 3 devise_for :users 4 # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html 5 get 'prototype/users' 6 root to: "prototype#index" 7 resources :prototype, only: [:index, :new, :create] 8 resources :users, only: [:edit, :update, :show] 9end 10
試したこと
コードなど見直し
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。