The goal of this tutorial is to capture the image from the web cam and be able to upload it as if you are uploading an image in your Ruby on Rails project.


#batman#dc#dc comics#tim drake#bruce wayne#batfam#batfamily#dick grayson#dc fanart

seen from United States

seen from Malaysia
seen from China

seen from Malaysia
seen from France

seen from Chile

seen from United States
seen from China

seen from Australia
seen from Yemen

seen from Russia

seen from Canada
seen from Sweden
seen from China

seen from France
seen from China
seen from China
seen from Malaysia
seen from Türkiye
seen from Canada
The goal of this tutorial is to capture the image from the web cam and be able to upload it as if you are uploading an image in your Ruby on Rails project.
Carrierwave: Update image versions
Product.all.each { |x| x.product_images.each { |img| img.picture.recreate_versions! } }
[coding] : passing parameters to carrierwave uploads
TL:DR; If you want to use jCrop, carrierwave and fog to crop images BEFORE they are uploaded to the cloud, do the following:
1) Add instance variables to your model:
2) permit those params in the controller (be careful about the order, the file needs to be the LAST thing you pass):
3) add the cropping method to your uploader and add process :crop to the version you want to have cropped:
That’s it :) Interested about the long story?
use #carrierwave to save image from #mechanize in #ruby
you need to convert the object from a Mechanize::Image object to one that carrierwave will recognize. You do this by using the old Ruby standby class File.
In development, you can just save the image anywhere in your file directory. But in production, specifically in @heroku, you are limited from saving any files to the directory. So using our existing carrierwave route that we created for allowing users to upload avatars, I did the following:
captcha_el = login.search('img')[4].attributes['src'] captcha_file = @agent.get(captcha_el).save! 'captcha1.jpg' file = File.open(captcha_file) user = User.find(1) user.update! avatar: file
in this example, to make it easy on myself, I’m saving the image as the avatar for a dummy user account created specifically for that purpose. That way, I don’t need to create any new models. This is a hack but it saves time. the User model looks like the following:
class User < ActiveRecord::Base mount_uploader :avatar, AvatarUploader end
and the AvatarUploader model:
class AvatarUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick end
Rails: 添付ファイルの表示
CarrierWaveなどでアップロードしたファイルをviewで表示する、というのがよくある。けどデフォルトの挙動では、添付ファイルのリンクを踏む(ファイルのパスにアクセスする)と、ファイルのダウンロードが始まってしまい、ちょっと憂鬱だった。
PDFや画像などはそのままブラウザで見たいので、ダウンロードではなくブラウザ内で表示させるには、
send_file(filepath, filename: @memo_file[:filename], disposition: 'inline')
とすればOK。別タブで表示するには、別途viewファイルでのリンクにtarget: '_blank'の指定もすればよろし。
After being asked about how to use Fixtures in CarrierWave (the Rails file uploader), I wrote an article about how I’d do it.
carrierwave rename exist filename
二种方法,推荐第二种
https://gist.github.com/38232602c169c508c2c4.githttps://gist.github.com/38232602c169c508c2c4.git