こんにちは@yukifreeworld12です。
自分用メモ
ストロングパラメーターのkeysが間違っていて画像が保存されず書き方を調べてうまくいったのでメモ。
Deviseを使っている場合の画像用のストロングパラメーター。
モデル作成+アップローダー作成後にストロングパラメーターを追加
↓
keysはregistration.htmlなどのフォームを見ればわかるのでそれを全部追加
↓
アップローダーの紐付け
app/models/user.rb
mount_uploader :avatar, AvatarUploader
今回の場合↓
registration_controller.rb
protected
def configure_account_signup_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :image, :email, :password, :password_confirmation])
end
def configure_account_update_params
devise_parameter_sanitizer.permit(:account_update, keys: [:username, :image, :image_cache, :remove_image, :email, :password, :password_confirmation, :current_password])
end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end
最後に
今日も見てくれてホンマありがとな!!
記事がええなと思ったらフォローといいねホンマよろしくな!!
(ジョーブログ風に)