gpt4 book ai didi

Cloudinary is working just fine from the rails console, but not from the form(Cloudinary在Rails控制台上工作得很好,但在表单中却并非如此)

转载 作者:bug小助手 更新时间:2023-10-27 19:57:26 24 4
gpt4 key购买 nike



I'm building a blog using ruby on rails.

我在用ruby on rails写博客。


Now I want to implement Cloudinary to handle de images from my development environment.

现在,我想实现Cloudinary来处理我的开发环境中的de映像。


**I had checked on the Active Storage configuration and also cloudinary, but I'm not able to find the error.
**
I can successfully upload pictures from rails console (rails c), but when I attempt to upload it from the form and click on create article, it displays the following error message:

**我检查了活动存储配置和Cloudinary,但找不到错误。**我可以从rails控制台(Rails C)成功上传图片,但当我尝试从表单上传图片并单击创建文章时,它显示以下错误消息:


Error image

错误图像



Missing configuration for the cloudinary Active Storage service. Configurations available for the test and local services.



#line 15

14 def create
15 @article = Article.new(article_params)
16 if @article.save
17 redirect_to @article
18 else


Can someone give me a hand to find out where is the error and how to fix it?
The project code is available here:
https://github.com/ThePalmeraTech/la-central

谁能帮我找出错误在哪里,以及如何修复它?项目代码可在此处获得:https://github.com/ThePalmeraTech/la-central


Thank you!

谢谢!


更多回答
优秀答案推荐

You don't have cloudinary set as your active storage service, and you don't have cloudinary storage service configured

您没有将Cloudinary设置为活动存储服务,也没有配置Cloudinary存储服务


Assuming you're using the cloudinary gem, scroll down to the Active Storage Integration section and step through the setup docs.

假设您正在使用Cloudinary gem,向下滚动到活动存储集成部分并逐步浏览设置文档。



I was able to upload the picture to Cloudinary now

我现在可以把照片上传到Cloudinary了


controller code:

控制器代码:


 def create
@article = Article.new(article_params)
if params[:article][:photo].present?
uploaded_image = Cloudinary::Uploader.upload(params[:article][:photo])
end

if @article.save
redirect_to @article
else
render :new, status: :unprocessable_entity
end
end

更多回答

Yes I do have both configured and set. I got to upload the pictures to cloudinary from the form now, the problem is that it is not being displayed in the views. Thank you for your answer

是的,我确实配置了和设置了。我现在要把照片从表格上传到Cloudinary,问题是它没有显示在视图中。感谢您的答复

Those are links to your own project showing that you don't have those set.

这些是指向您自己的项目的链接,表明您没有设置这些链接。

Aww, I see what you mean now. Well, the current version is in the "cloudinary-cdn" branch, where I do have those configuration done. In the case of storage.yml file, I'm providing my keys in ".env" and avoiding to get that published on github. Thank you Smathy!

啊,我现在明白你的意思了。好的,当前版本在“CLOUDINARY-CDN”分支中,我确实在那里完成了这些配置。对于storage.yml文件,我在“.env”中提供了我的密钥,并避免将其发布到GitHub上。谢谢你,斯玛西!

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com