Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails,活动记录,设计和云计算,简单形式,heroku。。。照片未上载到我的cloudinary_Ruby On Rails_Heroku_Activerecord_Devise_Simple Form - Fatal编程技术网

Ruby on rails Rails,活动记录,设计和云计算,简单形式,heroku。。。照片未上载到我的cloudinary

Ruby on rails Rails,活动记录,设计和云计算,简单形式,heroku。。。照片未上载到我的cloudinary,ruby-on-rails,heroku,activerecord,devise,simple-form,Ruby On Rails,Heroku,Activerecord,Devise,Simple Form,好的,你可以在标题中找到我问题的要点。我在rails中创建了一个应用程序,它要求用户创建个人资料并上传图片,以便访问一些功能。 不管怎样,除了图片上传部分,一切都正常 我对这一切都不熟悉,我对Desive尤其感到困惑。我正在寻找用户控制器,我应该在那里找到用户的创建操作,对吗?但我不知道在哪里能找到它 尽管如此,我甚至不确定问题是否来自控制器。问题的根源可能是简单的形式吗?不知道。我已经搜索和尝试了很长一段时间,我想是时候问问社区了:) 我将分享我能想到的与问题有关的一切。如果你还需要我展示什么

好的,你可以在标题中找到我问题的要点。我在rails中创建了一个应用程序,它要求用户创建个人资料并上传图片,以便访问一些功能。 不管怎样,除了图片上传部分,一切都正常


我对这一切都不熟悉,我对Desive尤其感到困惑。我正在寻找用户控制器,我应该在那里找到用户的创建操作,对吗?但我不知道在哪里能找到它


尽管如此,我甚至不确定问题是否来自控制器。问题的根源可能是简单的形式吗?不知道。我已经搜索和尝试了很长一段时间,我想是时候问问社区了:)


我将分享我能想到的与问题有关的一切。如果你还需要我展示什么,请告诉我


1/用户模型:

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable
  has_many :user_instruments, dependent: :destroy
  has_many :instruments, through: :user_instruments
  has_many :messages, dependent: :destroy
  has_one_attached :photo, dependent: :destroy
  has_many :reviews_written, class_name: "Review", foreign_key: :writer_id
  has_many :reviews_received, class_name: "Review", foreign_key: :receiver_id
  has_many :jam_sessions, dependent: :destroy

  def profile_picture
    if photo.attached?
      photo.key
    else
      "avatar-unknown.png"
    end
  end

  def full_name
    "#{first_name} #{last_name}"
  end
end

5/I在config/storage.yml中添加了这一行

cloudinary:
  service: Cloudinary

6/我在终端中执行了必要的步骤,将cloudinary配置到我的heroku:


heroku config:set CLOUDINARY\u URL=cloudinary://166....


我错过什么了吗


任何人的帮助都将不胜感激!
Olivier

您忘记将其作为强参数添加到注册中。由于这是由设备处理的,因此必须将其添加到应用程序控制器中的方法中,如下所示:

def configure_permitted_parameters
  devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :bio, :photo])
end

嘿,谢谢你的贡献。我忘了提,但是的,我提了。我在我的终端检查了heroku,cloudinary的钥匙在那里……非常感谢你,克拉拉!你又一次解决了我几个小时来一直在努力解决的问题:)
config.active_storage.service = :cloudinary
cloudinary:
  service: Cloudinary
def configure_permitted_parameters
  devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :bio, :photo])
end