Renaming uploaded files with Carrierwave

Well, another problem with your random filename generator is that it’s possible to have collisions isn’t it? You could possibly generate a filename that was already generated. One way to go about it would be to somehow generate a hash based on unique properties of the image, like file path. An example, from the carrierwave … Read more

Seeding file uploads with CarrierWave, Rails 3

Turns out the documentation for CarrierWave is slightly wrong. There is a more up to date piece of code in the README at the GitHub repository for the project. In a nutshell, though: pi = ProductImage.create!(:product => product) pi.image.store!(File.open(File.join(Rails.root, ‘test.jpg’))) product.product_images << pi product.save!

carrierwave – rails 3.1- undefined method: image_will_change

The OP comments that he fixed it, however there’s no answer set so I thought I’d add one for people coming across this in the future, which included myself until I figured it out 🙂 undefined method `x_will_change!’ for # happens if you forget to add a column in your model’s db table. If you … Read more

Uploading a remote file url from Rails Console with Carrierwave

Take a look at the ‘Uploading files from a remote location‘ section on this page https://github.com/carrierwaveuploader/carrierwave CarrierWave should throw an error if the url of the location is invalid 2.1.3 :015 > image.remote_image_url = “http” => “http” 2.1.3 :016 > image.save! (0.2ms) BEGIN (0.2ms) ROLLBACK ActiveRecord::RecordInvalid: Validation failed: Image trying to download a file which … Read more

Rails 3 paperclip vs carrierwave vs dragonfly vs attachment_fu [closed]

I’ve used both Paperclip and Carrierwave, and if I were you, I’d go for Carrierwave. It’s a lot more flexible. I also love the fact that it doesnt clutter your models with configuration. You can define uploader classes instead. It allows you to easily reuse, extend etc your upload configuration. Did you watch the Carrierwave … Read more

tech