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

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

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

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

Q&A

解決済

1回答

4612閲覧

deviseの複数モデルでのストロングパラメーターの実装がわかりません。

s.k

総合スコア423

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

0グッド

0クリップ

投稿2016/10/04 02:13

こんにちは。

【環境】
gem 'rails', '4.2.5'
devise (4.2.0)

【やりたいこと】

deviseを使った複数モデルでのsign_upの実装。

【現状】

以下の記事を参考にdeviseでモデルとコントローラーを作成しました。
http://qiita.com/Yama-to/items/54ab4ce08e126ef7dade

https://second-app-sagae.c9users.io/users/sign_upページで
sign upボタンを押すと

Email can't be blank
Password can't be blank
Username can't be blank

というエラー表示がでて先に進めません。
ちなみに、validationはusername以外はつけてません。

原因がわからなく大変困っております。
registrations_controller.rbのコードは以下です。

class Users::RegistrationsController < Devise::RegistrationsController before_action :configure_sign_up_params, only: [:create] #before_filter :configure_permitted_parameters, if: :devise_controller? # before_action :configure_account_update_params, only: [:update] # GET /resource/sign_up #def new #@user = User.new #end # POST /resource def create @user = User.new @user = User.new(configure_sign_up_params) if @user.save flash[:success] = "Welcome to the Sample App!" redirect_to @user 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 configure_sign_up_params devise_parameter_sanitizer.permit(:sign_up, keys: [:username]) 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

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

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

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

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

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

guest

回答1

0

自己解決

恐ろしいほど簡単でした。
gemをカスタマイズするのは最初苦労しますねぇ。

Rails の認証プラグイン Devise での Strong Parameters について

投稿2016/10/19 07:14

s.k

総合スコア423

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.49%

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

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

質問する

関連した質問