carrierwave

Duplicating a record that contains a carrierwave avatar : Getting “can't convert nil into Integer” error

前提是你 提交于 2019-12-12 02:33:12
问题 Protocol has_many Images. I am using local storage. In a controller, I am copying @protocol to @ dest and I use: @protocol.images.each do |i| tmp=i.dup tmp.avatar = File.open(i.avatar.current_path) tmp.save! @dest.images << tmp end The line: tmp.avatar = File.open(i.avatar.current_path) Throws this error: "can't convert nil into Integer" Shell session looks like this: >> i.avatar.current_path => "/Users/perry_mac/rails_projects/mymri/public/system/images/avatars/000/000/097/original/ruby.jpg"

rails custom validator to validate mime types with carrier wave

时光怂恿深爱的人放手 提交于 2019-12-12 02:19:37
问题 I am using the following way to validate the mime type of uploaded file content with carrier wave. https://gist.github.com/denyago/1298417 But this validation is running all the time even when no content is uploaded. This obviously fails as there is nothing to validate. validates :logo, :file_mime_type => {:content_type => /image/} Is there any work around to skip validation when no content is uploaded? Thanks !! UPDATE: Using the proc or lambda work well till there is no uploaded content

Rails upload files to Amazon S3 with carrierwave and fog

别来无恙 提交于 2019-12-12 01:26:57
问题 I tried to upload movie files from my rails application to Amazon S3. First I tried paperclip, but it dosn't worked ... No I tried carrierwave + fog but same result nothing worked, no files stored in S3 no database entry and no errors ... My Files look like this: app/uploader/movie_uploader.rb class MovieUploader < CarrierWave::Uploader::Base storage :fog def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end config/initializers/carrierwave.rb CarrierWave

Photos uploaded by mobile with carreirwave/dropzone are rotated correctly in s3 but are showing up sideways on my webapp

被刻印的时光 ゝ 提交于 2019-12-12 01:13:34
问题 When a User uploads photos with a mobile phone using Carrierwave/Dropzone the photos will sometimes be sideways in the preview, however the photos are being saved in s3 with the correct rotation. However, despite being saved in s3 with the correct rotation, when they are then shown on the web app, they are again being shown sideways. Very confusing. 回答1: Here's the code to get it working class AvatarUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick process :auto_orient

rails carrierwave - image url saved in db but file not saved

♀尐吖头ヾ 提交于 2019-12-11 23:29:51
问题 I have a form where I use cropit.js to crop an image. Button is onclick calling jquery function which takes result of cropit (cropped image) and with ajax push it to controller. Here it seems to work, but when I do this, everything looks ok, I dont see any error but the result is that url is stored in database with file name, but file itself is not stored in default uploads directory here is my model class Project < ActiveRecord::Base mount_uploader :profile_pic, ProjectProfileUploader end

Carrierwave encode file to base64 as process

◇◆丶佛笑我妖孽 提交于 2019-12-11 20:54:19
问题 I am trying to solve this. I would like to encode file as base64 as one of the process. My code so far looks like class ImageUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick include CarrierWave::MimeTypes storage :file def extension_white_list %w(jpg jpeg png) end def store_dir "/tmp/images/#{model.class.to_s.underscore}/#{model.id}" end process :set_content_type process :format_to_jpg process :strip_metadata process :encode_base64 def format_to_jpg manipulate! do |img|

Carrierwave +repage option not working

旧城冷巷雨未停 提交于 2019-12-11 19:51:32
问题 In my Carrerwave custom process method, I'm attempting to use the +repage option. Documentation was kind of hard to come across, but I found that I needed to run img.repage.+ . However that didn't work out as it didn't even try to convert the option to +, but kept it at -repage and threw an error illustrating as much. Then I found a page which illustrated to write it out as: img.push '+repage' img.+ img.repage It used a different example (not using repage, but using '+profile' with two

CSS doesn't load on Heroku, when I enabled an asset server (AWS) to serve images? Using Rails4, Carrierwave, Heroku, Amazon S3

*爱你&永不变心* 提交于 2019-12-11 18:54:18
问题 I have an app on Heroku and finally managed to save uploaded images (using Carrierwave) to Amazon S3, they show in my bucket and all is fine, but I had to add this to my production.rb: # Enable serving of images, stylesheets, and JavaScripts from an asset server. config.action_controller.asset_host = "https://s3-us-west-1.amazonaws.com/mybucket" However now there is something wrong with my asset pipeline. It looks for the CSS and Javascript from the config.action_controller.asset_host and I

Rails / Carrierwave gem - How can I access the image upload data as JSON?

不羁岁月 提交于 2019-12-11 17:52:03
问题 The Carrierwave gem allows me to enable users to upload one or more images (e.g., an avatar) and to display these images on a Rails-generated page, thus: <%= image_tag(@user.avatar_url(:thumb)) %> I'm wondering whether it's possible to retrieve the image data as JSON such that I receive a JSON response that looks like this: [ { "title": "The Title", "description": "The description", "url": "the/url", "thumbnail: "the/thumbnail/url" } ] 回答1: Inside of a controller create a method (example

carrierwave png thumbnails from svg upload

喜夏-厌秋 提交于 2019-12-11 17:42:44
问题 Using ruby on rails. I want carrierwave upload of an SVG file to make .png thumbnails. I'm having trouble with the syntax of getting carrierwave to convert the files to png. This is close, and the contents of the thumbnails are png data, but the filename extension is .svg class SvgUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick storage :file version :thumb do process :convert => 'png' process resize_to_fit: [50, 50] end version :thumb_small do process :convert => 'png'