to_model delegated to attachment, but attachment is nil

前端 未结 2 1349
囚心锁ツ
囚心锁ツ 2021-01-28 10:47

So I asked this question already here: previous question and didn\'t get much help, I looked for other questions similar to mine, but no resolution. So I\'ll ask the question ag

相关标签:
2条回答
  • 2021-01-28 10:59

    It seems that you don't have a banner image for the user. If your view layout breaks because the user has no banner so use conditional if in your code

    image_tag url_for(@user.banner_image) if @user.banner_image.present?
    

    Or you may want to have a fallback image to preserve the layout

    image_tag url_for(@user.banner_image || '/public/fallback_banner_image.jpg')
    

    The above line is an example but you will need to include an actual file image/path

    0 讨论(0)
  • ISSUE RESOLVED:

      # If you have extra params to permit, append them to the sanitizer.
      def configure_sign_up_params
        devise_parameter_sanitizer.permit(:sign_up, keys: [:firstname, :image])
      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: [:firstname, :image])
      end
    

    so the configure_account_update_params defenition was set to permit the :signup not :account_update. I changed it to :account_update and it worked!

    0 讨论(0)
提交回复
热议问题