简体   繁体   English

如何在生产中的rails app中从paperclip上传视图图像?

[英]How to get view image uploaded from paperclip in rails app in production?

I am using paperclip in my rails app. 我在我的rails应用程序中使用回形针。 In the development environment, when I go to the url where the image is stored I am able to view it. 在开发环境中,当我转到存储图像的URL时,我能够查看它。 However in production, I get an error saying that this page does not exist. 但是在生产中,我收到一条错误消息,指出此页面不存在。 Any advice on how to fix this? 关于如何解决这个问题的任何建议?

Where are you hosting the application on? 你在哪里托管申请? If it's Heroku, then it will not allow uploads, because Heroku has a read-only file system. 如果它是Heroku,那么它将不允许上传,因为Heroku有一个只读文件系统。 Therefore, you will have to look for a third party solution such as S3 to host your uploaded images. 因此,您必须寻找第三方解决方案(如S3)来托管您上传的图像。

It depends on what you are using for production. 这取决于您用于生产的内容。 Some places like Heroku won't allow you to host images, so you need to use something external such as Amazon S3. 像Heroku这样的地方不允许你托管图像,因此你需要使用外部设备,如Amazon S3。 Also, to get the url you can go to rails console and try to get the url of the image by typing in an instance of the model that has an image attached to it and then calling .image.url (assuming image is the name of the column) 此外,要获取URL,您可以转到rails控制台并尝试通过键入附加了图像的模型实例然后调用.image.url来获取图像的URL(假设image是名称专栏)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails回形针上传后立即上传图片路径 - Rails paperclip get uploaded image path once uploaded 使用回形针gem上传图像时,Heroku Rails应用程序崩溃 - Heroku Rails app crashes when image is uploaded using paperclip gem 将回形针图像从控制器传递到导轨视图 - passing a paperclip image from the controller to a view in rails 另一个视图的Rails回形针访问图像 - rails paperclip access image from another view 如何使用 ruby​​ on rails 中的回形针即时预览上传的图像 - How to preview uploaded image instantly with paperclip in ruby on rails 在Rails中,如何通过回形针将上传的文件(图像或pdf)保存到数据库? - In rails, how to save uploaded files (image or pdf) through paperclip to database? 如何在我的Rails应用程序中编辑production.rb以使其使用heroku和回形针正常工作? - How to edit production.rb in my rails app to get it working using heroku and paperclip? rails回形针-更改上传图像的宽高比 - rails paperclip - changing aspect ratio of uploaded image 从带有回形针宝石红宝石的视图中访问不同视图中的图像 - Access image from different view in a view with paperclip gem ruby on rails 如何从曲别针导轨中的url保存图像 - how to save image from url in paperclip rails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM