carrierwave

How to delete the original files and keep only the versions using CarrierWave?

大憨熊 提交于 2019-12-08 07:17:00
问题 I'm trying this but without luck. class FileUploader < CarrierWave::Uploader::Base after :cache, :unlink_original def unlink_original(file) file.delete end . . end 回答1: Figured it out. There was a typo in the docs. Fixed it with the following. class FileUploader < CarrierWave::Uploader::Base after :store, :unlink_original def unlink_original(file) File.delete if version_name.blank? end . . end 来源: https://stackoverflow.com/questions/9557911/how-to-delete-the-original-files-and-keep-only-the

Carrierwave default image doesn't display

[亡魂溺海] 提交于 2019-12-08 05:53:51
问题 I'm trying to have a default image display in my Rails 3.2 application. I've followed the instructions on the Carrierwave github page and have looked through several Stackoverflow posts. But, for some reason it's still not working. Here is my code: In my photo_uploader.rb file I've enabled this: def default_url "/images/" + [version_name, "default.png"].compact.join('_') end In my form and show views I'm accessing the image like this: <%= image_tag @user.photo.url %> The path to my image is:

Rails convert Paperclip directory structure to Carrierwave

你离开我真会死。 提交于 2019-12-08 05:53:38
问题 I was using the Paperclip gem: https://github.com/thoughtbot/paperclip I'm now using Carrierwave: https://github.com/carrierwaveuploader/carrierwave My production website is currently using Paperclip. I'm going to be updating the production website to use Carrierwave. The folder structure for uploads in Paperclip differs from Carrierwave. I'm also using Amazon S3 to store uploads. I'm wondering if there's a way to convert my production files uploaded with Paperclip to Carrierwave. For example

carrierwave :thumb wrong number of arguments

大城市里の小女人 提交于 2019-12-08 04:37:57
问题 I'm following along with Ryan Bates' carrierwave Railscast http://railscasts.com/episodes/253-carrierwave-file-uploads. At one point, after resizing the images into a thumbnail, he displays the thumbnail with the following code <%= image_tag painting.image_url(:thumb).to_s %> I'm calling the url method on the profilepic instance variable and trying to get the thumbnail like this <%= image_tag @profilepic.url(:thumb).to_s %> But I get the error wrong number of arguments (1 for 0) It's not

How to process only on original image file using CarrierWave?

三世轮回 提交于 2019-12-08 02:02:18
问题 I use CarrierWave to generate versions (thumbnails with different sizes) and also to add a watermark on each versions. I have currently manage to apply the watermark for each thumbnails but I would like to add it on the original image to. Here is what I tried: def watermark manipulate! do |img| watermark = Magick::Image.read(Rails.root.join('app/assets/images/watermark_512.png')).first img = img.composite(watermark, Magick::CenterGravity, Magick::OverCompositeOp) end end version :original do

active_admin and adding multiple images to gallery

非 Y 不嫁゛ 提交于 2019-12-07 19:28:09
问题 I'm using active_admin and carrierwave gems. Have two simple models: class Image < ActiveRecord::Base attr_accessible :gallery_id, :file belongs_to :gallery mount_uploader :file, FileUploader end class Gallery < ActiveRecord::Base attr_accessible :description, :title, :file, :images_attributes has_many :images accepts_nested_attributes_for :images, allow_destroy: true mount_uploader :file, FileUploader end Now my active_admin form for Gallery looks like this: form do |f| f.inputs "Gallery" do

Carrierwave with Dropzone JS. Is it possible to use these with nested attributes?

六月ゝ 毕业季﹏ 提交于 2019-12-07 14:51:21
问题 Currently, I have several forms that work with nested attributes. I found out recently about Dropzone JS, so I wanted to implement it in various forms I'm using. I have two models similar to these: Games class Games < ActiveRecord::base has_many :screenshots, dependent: :destroy accepts_nested_attributes_for :screenshots, allow_destroy: true end Screenshots class Screenshot < ActiveRecord::Base belongs_to :game mount_uploader :ssfile, ScreenshotUploader end Normally, I'd handle it with

Using jCrop with cloudinary through rails 4 to crop before creating image

做~自己de王妃 提交于 2019-12-07 14:02:58
问题 I've been at this for some time now. I"m using cloudinary to upload photos and am trying to implement a cropping feature using jcrop on a photo create action. After I implemented cloudinary I followed railscasts #182 on Jcrop. I think I'm having problems getting the new cropped parameters (x,y,w,h) back to the uploader before the image is saved. Update: I'm not even getting the values put into the f.text_fields. When I move the cropper around, there should be new values right? Here's a pic of

uninitialized constant CarrierWave

淺唱寂寞╮ 提交于 2019-12-07 10:23:32
问题 I am deploying my first rails app using passenger and capistrano. every thing is fine until i faced this error when I tried to launch the app in the browser. Error message: uninitialized constant CarrierWave Exception class: NameError you can see the message in details at http://test.ajhezaty.com/ the site works perfectly locally and CarrierWave uploading the image correctly. I tried to restart the VPS server by running sudo /etc/init.d/httpd2 restart but it didnt fix the issue. for your

how do I add files already stored on s3 to carrierwave backed by same datastore?

荒凉一梦 提交于 2019-12-07 10:15:45
问题 I already have files in my s3, which were uploaded via FTP, and I'd just like to attach them to my models, which allow upload via CarrierWave, if I'm using the same bucket to store the files I upload via CarrierWave and the ones I upload via FTP, is there a way to just assign the s3 key for the file to the (new) associated record (via a model) where the file itself is handled via CarrierWave's attachment strategy? 回答1: Assuming you have the thumbnails already created, and can store the files