capturing an image from the webcam
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.
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
精彩评论