質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Q&A

1回答

927閲覧

Rails deviseの新規登録ページでユーザー情報をsave出来ない

TaigaYoshizaki

総合スコア12

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

0グッド

1クリップ

投稿2019/08/12 03:13

Rails devise 新規登録ページでユーザー情報をsave出来ない


イメージ説明

deviseでregistration/new.html.erbを編集して既存のフォーム以外新たなフォームを追加し、実装したのですが、保存出来ません。

gemはdevise以外にエラーメッセージを表示させる為にgem 'rails-i18n', '~> 5.1'を導入しています。

registration/new.html.erb =>ユーザー用の登録フォーム

<h3 style="padding-left: 200px; padding-top: 20px;">新規登録</h3> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= render "devise/shared/error_messages", resource: resource %> <div class="mx-auto container"> <div class="form-group form-inline row"> <div class="field col-3"> <%= f.label:名前(姓), class: "float-left" %><br /> <%= f.text_field :first_name, autofocus: true, class: "col-lg-offset-3 form-control form-control-lg w-100" %> </div> <div class="field col-3"> <%= f.label :名前(名), class: "float-left" %><br /> <%= f.text_field :last_name, class: "col-auto form-control form-control-lg w-100" %> </div> </div> <div class="form-group form-inline row"> <div class="field col-3"> <%= f.label :名前(セイ), class: "float-left" %><br /> <%= f.text_field :first_name_ruby, class: "col-auto form-control form-control-lg w-100" %> </div> <div class="field col-3"> <%= f.label :名前(メイ), class: "float-left" %><br /> <%= f.text_field :last_name_ruby, class: "col-auto form-control form-control-lg w-100" %> </div> </div> <div class="field col-6"> <%= f.label :郵便番号(ハイフン無しで入力して下さい) %><br /> <%= f.text_field :zip_code, class: "col-auto form-control form-control-lg w-100" %> </div> <div class="field col-6"> <%= f.label :住所 %><br /> <%= f.text_field :address, class: "col-auto form-control form-control-lg w-100" %> </div> <div class="field col-6"> <%= f.label :電話番号(ハイフン無しで入力して下さい) %><br /> <%= f.number_field :phone_number, class: "col-auto form-control form-control-lg w-100" %> </div> <div class="field col-6"> <%= f.label :メールアドレス %><br /> <%= f.email_field :email, autocomplete: "email", class: "col-auto form-control form-control-lg w-100" %> </div> <div class="field col-6"> <%= f.label :パスワード %> <% if @minimum_password_length %> (<%= @minimum_password_length %> 文字以上入力してください) <% end %><br /> <%= f.password_field :password, autocomplete: "new-password", class: "col-auto form-control form-control-lg w-100" %> </div> <div class="field col-6"> <%= f.label :パスワード(確認) %><br /> <%= f.password_field :password_confirmation, autocomplete: "new-password", class: "col-auto form-control form-control-lg w-100" %> </div> <div class="actions text-right col-9"> <%= f.submit "同意して次へ", class: "btn btn-success mx-auto btn-lg" %> </div> </div>

schema.rb

# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 2019_08_10_074530) do create_table "addresses", force: :cascade do |t| t.integer "user_id", null: false t.string "name", null: false t.string "zip_code", null: false t.string "address", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "admins", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["email"], name: "index_admins_on_email", unique: true t.index ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true end create_table "artists", force: :cascade do |t| t.string "name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["name"], name: "index_artists_on_name" end create_table "carts", force: :cascade do |t| t.integer "user_id", null: false t.integer "product_id", null: false t.integer "quantity", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "consts", force: :cascade do |t| t.string "name", null: false t.integer "value", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "genres", force: :cascade do |t| t.string "name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["name"], name: "index_genres_on_name" end create_table "labels", force: :cascade do |t| t.string "name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["name"], name: "index_labels_on_name" end create_table "order_products", force: :cascade do |t| t.integer "order_id", null: false t.integer "product_id", null: false t.integer "quantity", null: false t.integer "price", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "orders", force: :cascade do |t| t.integer "user_id", null: false t.string "zip_code", null: false t.string "address", null: false t.string "phone_number", null: false t.integer "postage", null: false t.integer "total", null: false t.integer "payment", default: 0, null: false t.integer "status", default: 0, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "products", force: :cascade do |t| t.string "name", null: false t.integer "artist_id", null: false t.integer "label_id", null: false t.integer "genre_id", null: false t.integer "price", null: false t.integer "stock", null: false t.text "jacket_image_id" t.text "summary" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["name"], name: "index_products_on_name" end create_table "tracks", force: :cascade do |t| t.integer "product_id", null: false t.integer "disc", default: 1, null: false t.integer "number", null: false t.string "name", null: false t.string "length", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.string "first_name", null: false t.string "last_name", null: false t.string "first_name_ruby", null: false t.string "last_name_ruby", null: false t.string "phone_number", null: false t.string "zip_code", null: false t.string "address", null: false t.boolean "user_deleted", default: false, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["email"], name: "index_users_on_email", unique: true t.index ["first_name"], name: "index_users_on_first_name" t.index ["first_name_ruby"], name: "index_users_on_first_name_ruby" t.index ["last_name"], name: "index_users_on_last_name" t.index ["last_name_ruby"], name: "index_users_on_last_name_ruby" t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end end

よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

追加したカラムを保存するにはstrong parameters設定が必要になります。

Users::RegistrationsController
に下記の内容を追記したら保存できるようになるかと思います。

protected # 例えば、nameを追加した場合 def configure_sign_up_params devise_parameter_sanitizer.permit(:sign_up, keys: [:name]) end def configure_account_update_params devise_parameter_sanitizer.permit(:account_update, keys: [:name]) end

投稿2019/08/29 09:03

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問