Soceryを使ってユーザー登録機能とログイン認証機能を作っているんですが、
password_comfirmationを入れた途端、UnknownAttributeErrorが出てしまいました。
Userテーブルの中のパスワードのカラムはcrypted_passwordだけで良いんですよね?
どのsorcery関連の記事でも当たり前のようにpassword_comfirmationを使っていて、原因がわからず質問させていただきました。
まずこちらがusers_controllerです
class UsersController < ApplicationController def new @user = User.new end def show @user = User.find(params[:id]) end def create @user = User.new(user_params) if @user.save redirect_to user_path(@user), notice: "Signed up!" else render :new, notice: "Failed to signin" end end private def user_params params.require(:user).permit(:username, :password, :password_confirmation, :usertype) end end
こちらがpassword_comfirmationを使ったviewです。
%h2 新規ユーザー登録 = form_for @user do |f| .field = f.label :username, "ユーザーID" = f.text_field :username .field = f.label :password, "パスワード" = f.password_field :password .field = f.label :password_confirmation, "パスワード確認" = f.password_field :password_confirmation .field = f.label :usertype, "ユーザー区分" = f.select :usertype, User.usertypes_i18n.keys.map {|k| [User.usertypes_i18n[k], k]} .actions = f.submit "登録" %p or = link_to "login", new_session_path
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/18 09:03
2018/07/18 11:24
2018/07/19 07:45
2018/07/19 07:56