Lorenzo Cunha
Lorenzo Cunha

Reputation: 19

Show image paperclip after query

I have a column called resolution_image type boolean in the paperclip images table. I want to show the image where the field resolution_image is true, how do i show this image?

Upvotes: 0

Views: 47

Answers (2)

steakchaser
steakchaser

Reputation: 5239

Need some more details on your specific naming convention, but let's assume the following:

  1. You have a model with a paperclip attachment named model_with_image_attachment
  2. That model has an attachment which you've named attachment_name

This would display the image when the resolution_image attribute is true:

<%= image_tag model_with_image_attachment.attachment_name.url if model_with_image_attachment.resolution_image %>

Upvotes: 0

Raj
Raj

Reputation: 22926

<%= image_tag @model.picture.url if @model.resolution_image %>

Upvotes: 2

Related Questions