从网络摄像头捕获图像
我在这里关注本教程:[link] 关于获取使用回形针和 jpegcam 将网络摄像头图像导入轨道。我按照教程进行了一遍又一遍,但我似乎无法上传图像。当我转到照片/节目时,我收到此错误:
NoMethodError in Photo#show
Showing app/views/photo/show.html.erb where line #3 raised:
undefined method `image' for nil:NilClass
Extracted source (around line #3):
1: <h1>Photo</h1>
2: <p>
3: <%= image_tag @photo.image.url(:medium) %>
4: <%= link_to "Take a new picture", new_photo_path %>
5: </p>
我也无法将任何图像上传到上传文件夹中。我是否犯了某种根本性的rails-noob错误?我正在运行 Windows XP、Rails 2.3.8、Ruby 1.8.7。我从 github 网站获取了 paperclip.git 作为 zip 文件,并且必须手动安装它,只需将其添加到我的插件文件夹中即可。我这样做是因为我无法从命令行提示符安装它。我不断收到错误“插件未识别为内部或外部命令”。但无论如何,我认为我的手动安装有效,因为我能够生成回形针并且所有列都迁移得很好。适当的 rake 任务也会出现在 rake 下拉列表中,所以我认为这不是问题。任何帮助将不胜感激。我真的想让这个工作起来,这样我就可以以此为基础。如果有人有任何想法,请告诉我。
I was following this tutorial here: [link] about getting a webcam image into rails using paperclip and jpegcam. I followed the tutorial through and through yet I can't seem to get the image uploaded. I'm getting this error when I go to photo/show:
NoMethodError in Photo#show
Showing app/views/photo/show.html.erb where line #3 raised:
undefined method `image' for nil:NilClass
Extracted source (around line #3):
1: <h1>Photo</h1>
2: <p>
3: <%= image_tag @photo.image.url(:medium) %>
4: <%= link_to "Take a new picture", new_photo_path %>
5: </p>
I also couldn't get any image to upload into the uploads folder. Am I making some sort of fundamental rails-noob mistake? I'm running windows xp, rails 2.3.8, ruby 1.8.7. I got the paperclip.git from the github website as a zip file and had to install it manually just by adding it into my plugins folder. I did this because I couldn't install it from the command line prompt. I kept getting the error "plugin not recognized as internal or external command." But anyway, I assume my manual install worked because I was able to generate the paperclip and all the columns migrated just fine. The appropriate rake tasks also appear in the rake dropdown so I don't think that's the problem. Any help would be really appreciated. I really wanna get this working so I can build off of it. Please let me know if anyone out there has any ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您的 @photo 实例变量尚未设置。请参阅 PhotosController 的 show 方法并确保在那里设置 @photo。
或者查看本文的 Rails 3 示例应用程序:https://github.com/lassebunk/webcam_app
It seems that your @photo instance variable is not getting set. Please see the PhotosController's show method and make sure @photo gets set there.
Alternatively take a look at a Rails 3 example application of this post: https://github.com/lassebunk/webcam_app