0

In my model pin.rb

has_attached_file :image, styles: { medium: "320x240>"}

In pin.html.erb

<td><%= image_tag pin.image(:medium) %></td>

When I upload an image it gives

No File Chosen Paperclip::Errors::NotIdentifiedByImageMagickError

However when I remove "styles..." from pin.rb and '(:medium) from pin.html it works fine. I want the image size to be adjusted though.

What am I doing wrong?

Sean L
  • 827
  • 1
  • 11
  • 22

2 Answers2

0

Aren't you forgetting to call url on the attachment?

<%= image_tag pin.image.url(:medium) %>
boulder
  • 3,256
  • 15
  • 21
0

Yes, this is a couple of years old and was never answered

I'm researching another Paperclip question today, but in this case I would say:

<%= image_tag @pin.image.url(:medium) %>

as that's the equivalent of what I have in mine.

Don't forget the instance variable in the _form.html.erb as well as the .url method to set the image into the size you want.

For any travelers to this page, as a next step you might want to also look at another post here on how to delete the image in the Edit view. Rails file upload (paperclip) on edit

Cheers

Community
  • 1
  • 1
sf2k
  • 592
  • 2
  • 6
  • 25