1

im tring to save the images I upload with paperclip to a specific path. I would like the Images to be saved in app/assets/image dir in the ruby on rails application, but they don't seem to go in there

this is what the path looks like in the config/environments/development.rb

config.paperclip_defaults = {
:url  => ":rails_root/app/assets/images/:attachment/:id/:style/:filename",    
:path => "/:class/:attachment/:id/:style/:basename.:extension"
}

I really appreciate any advice or help you can give me, if you would like more info I'll put it up as quick as I can.

here is the def create from the product_images showing how I create an image and save it

def create
 @product_image = ProductImage.new(params[:product_image])
 @product = @product_image.product

 if @product_image.save
  @product.product_image_id = @product_image.id
  @product.save

  redirect_to @product_image, notice: 'Product image was successfully created.'         
 else
  render :template => "products/edit"       
 end    
end
Joe Lloyd
  • 19,471
  • 7
  • 53
  • 81

1 Answers1

0

In your model that you're accessing paperclip, place this code inside of it rather than the development.rb file.

 has_attached_file :model_name,
 :path => ":attachment/:id/:style/:basename.:extension"
coletrain
  • 2,809
  • 35
  • 43
  • I don't see any change in the image dir. I'll add the def create p[art of the controller here so you can see if the image is being saved correctly. Its a little complicated as the product_images belongs_to product. – Joe Lloyd Oct 11 '13 at 15:30
  • 1
    I just re-read your question and thought about it. Rails puts the images into the public folder so if you would like to save your images you could create an images folder inside of the public folder and save them there. For this reason I use amazon s3. – coletrain Oct 11 '13 at 15:36