Closed Hiratto closed 2 years ago
`def update @profile = current_user.prepare_profile @profile.assign_attributes(profile_params) if @profile.save redirect_to profile_path, notice: 'プロフィール更新!' else flash.now[:error] = '更新できませんでした' render :edit end end
private def profile_params params.require(:profile).permit( :nickname, :introduction, :gender, :birthday, :subscribed ) end`
上記よく使うのでスニペット登録
`def update @profile = current_user.prepare_profile @profile.assign_attributes(profile_params) if @profile.save redirect_to profile_path, notice: 'プロフィール更新!' else flash.now[:error] = '更新できませんでした' render :edit end end
private def profile_params params.require(:profile).permit( :nickname, :introduction, :gender, :birthday, :subscribed ) end`
上記よく使うのでスニペット登録