0

I am using the gem PaperClip for upload images to my server , but the images are stored in public/system I need to change this ubication to app/assets/images

class User < ActiveRecord::Base
  attr_accessible :email, :name,:photo

  validates :name, :presence => true    
  validates :email, :presence => true
  has_attached_file :photo, :styles => 
           { :medium => "300x300>", :thumb => "100x100>" }

end

I found this tutorial of RailsCasts where these options are declared

has_attached_file :photo, :styles => { :small => "150x150>" },
                  :url  => "/assets/products/:id/:style/:basename.:extension",
                  :path => ":rails_root/public/assets/products/:id/:style/:basename.:extension"

validates_attachment_presence :photo
validates_attachment_size :photo, :less_than => 5.megabytes
validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png']
uday
  • 8,544
  • 4
  • 30
  • 54
daniel barrera
  • 347
  • 1
  • 4
  • 15
  • It's saved in public so you can be able to access it. There where it should be. I save mine in rails_root/public/assets/ – dima Dec 15 '14 at 07:55

1 Answers1

3

If you look at the PaperClip documentation there its stated:

The files that are assigned as attachments are, by default, placed in the directory specified by the :path option to has_attached_file. By default, this location is :rails_root/public/system/:class/:attachment/:id_partition/:style/:filename

So you need to specify the :path variable of has_attached_file to your desired path.

Hope it helps!

uday
  • 8,544
  • 4
  • 30
  • 54