こんにちは。
s.kです。
プロフィールページのデザインを改善したので、
プロフィールを入力して、出来を確認しようと考えたのですが、
deviseのvalidationで躓いてしまいました( ;∀;)
###前提・実現したいこと
プロフィール更新時のパスワードvalidationを解除したい。
deviseを実装しています。
###発生している問題・エラーメッセージ
自分なりにdeviseにおけるパスワード解除を実装したつもりなのですが、
プロフィールを更新すると
Password can't be blank
と、拒絶されてしまいます。
このようなエラーも発生していました。
DEPRECATION WARNING: You attempted to assign a value which is not explicitly `true` or `false` ("{:autofocus=>true}") to a boolean column. Currently this value casts to `false`. This will change to match Ruby's semantics, and will cast to `true` in Rails 5. If you would like to maintain the current behavior, you should explicitly handle the values you would like cast to `false`. (called from update_without_current_password at /home/ubuntu/workspace/app/models/user.rb:79)
###該当のソースコード
【user.rb】
・・・・省略・・・・ def password_required? provider.blank? # provider属性に値があればパスワード入力免除 end def update_without_current_password(params, *options) params.delete(:current_password) if params[:password].blank? && params[:password_confirmation].blank? params.delete(:password) params.delete(:password_confirmation) end result = update_attributes(params, *options) clean_up_passwords result end ・・・・省略・・・・
【registrations_controller.rb】
・・・・省略・・・・ def update self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key) prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email) #if update_resource(resource, account_update_params) if resource.update_without_current_password(account_update_params) yield resource if block_given? if is_flashing_format? flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ? :update_needs_confirmation : :updated set_flash_message :notice, flash_key end sign_in resource_name, resource, :bypass => true respond_with resource, :location => after_update_path_for(resource) else clean_up_passwords resource respond_with resource end end def update_resource(resource, params) resource.update_without_current_password(params) end ・・・・省略・・・・
###試したこと
Devise でユーザーがパスワードなしでアカウント情報を変更するのを許可こちらを参考にしてコードを書いてみました。
足りない情報をありましたら、リクエストお願い致します。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。