Arsalan T
Arsalan T

Reputation: 876

How to upload an uploaded image to carrier wave

I want to upload an image which is already being uploaded to my website. I want to show library to user and they will select one from it and it will be associated with the new record too.

Upvotes: 0

Views: 172

Answers (2)

AMBasra
AMBasra

Reputation: 969

Carrierwave gives you this feature to upload by providing the url. See the following code sample for help. Its taken from Ryan Bates railscasts. Its quite simple. http://railscasts.com/episodes/253-carrierwave-file-uploads Simply add the :remote_image_url field and use it in your form, enter the url and leave the rest to Rails and Carrierwave.

class Painting < ActiveRecord::Base
  attr_accessible :gallery_id, :name, :image, :remote_image_url
  belongs_to :gallery
  mount_uploader :image, ImageUploader
end

Hope this helps.

Upvotes: 0

Amar
Amar

Reputation: 6942

you can refer carrierwave home page

u = User.new
u.avatar = File.open('somewhere')
u.save!

Upvotes: 1

Related Questions