前提・実現したいこと
現在、rubyを使って、プラットフォームアプリを作成しています。
deviseを導入して、複数モデルを作成し、ログインを実行したところ
保存がされていませんでした。通常通りログインができるようにしたいです。
初学者ゆえ、もろもろ抜けているところなどありましたら、ご指摘いただければと思います。
発生している問題・エラーメッセージ
ターミナル Started POST "/speakers" for ::1 at 2020-10-01 14:33:00 +0900 Processing by Speakers::RegistrationsController#create as HTML Parameters: {"authenticity_token"=>"cMpj1qCQPUrcY8s44bXNgiKuqAIsaUdlQThsr0H4h63nFNKe+8+r6dMc5ewH/vLk5iIJxh1vj86UWztsmmKRVg==", "speaker"=>{"nickname"=>"wa", "email"=>"wa@wa", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "first_name"=>"あ", "last_name"=>"あ", "first_name_kana"=>"ア", "last_name_kana"=>"ア", "birth_date(1i)"=>"1931", "birth_date(2i)"=>"6", "birth_date(3i)"=>"5"}, "commit"=>"会員登録"} From: /Users/yuuri/projects/wacca/app/controllers/speakers/registrations_controller.rb:15 Speakers::RegistrationsController#create: 13: def create 14: @speaker = Speaker.new(speaker_signup_params) => 15: binding.pry 16: if @speaker.save 17: redirect_to root_path 18: else 19: render :new 20: end 21: end [1] pry(#<Speakers::RegistrationsController>)> @speaker => #<Speaker id: nil, first_name: nil, last_name: nil, first_name_kana: nil, last_name_kana: nil, nickname: "", email: "", birth_date: nil, created_at: nil, updated_at: nil> [2] pry(#<Speakers::RegistrationsController>)>
コントローラー # frozen_string_literal: true class Speakers::RegistrationsController < Devise::RegistrationsController before_action :speaker_signup_params, only: [:create] # before_action :configure_account_update_params, only: [:update] # GET /resource/sign_up def new @speaker = Speaker.new end # POST /resource def create @speaker = Speaker.new(speaker_signup_params) if @speaker.save redirect_to root_path else render :new end end # GET /resource/edit # def edit # super # end # PUT /resource # def update # super # end # DELETE /resource # def destroy # super # end # GET /resource/cancel # Forces the session data which is usually expired after sign # in to be expired now. This is useful if the user wants to # cancel oauth signing in/up in the middle of the process, # removing all OAuth session data. # def cancel # super # end protected # If you have extra params to permit, append them to the sanitizer. def speaker_signup_params devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name,:last_name,:first_name_kana,:last_name_kana,:email,:nickname,:birth_date]) end # If you have extra params to permit, append them to the sanitizer. # def configure_account_update_params # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute]) # end # The path used after sign up. # def after_sign_up_path_for(resource) # super(resource) # end # The path used after sign up for inactive accounts. # def after_inactive_sign_up_path_for(resource) # super(resource) # end end
あなたの回答
tips
プレビュー