Note that there are some explanatory texts on larger screens.

plurals
  1. POdefault pic when using multiple nested images on paperclip
    primarykey
    data
    text
    <p>I am using Paperclip to upload multiple item images. I followed some of this tutorial <a href="http://sleekd.com/general/adding-multiple-images-to-a-rails-model-with-paperclip/" rel="nofollow">http://sleekd.com/general/adding-multiple-images-to-a-rails-model-with-paperclip/</a> My models are:</p> <p>Item.rb</p> <pre><code>has_many :item_images, :dependent =&gt; :destroy accepts_nested_attributes_for :item_images, :reject_if =&gt; lambda { |l| l['item_image'].nil? } </code></pre> <p>ItemImage.rb</p> <pre><code>class ItemImage &lt; ActiveRecord::Base belongs_to :item belongs_to :user #for image. Paperclip following Bootstrap sizes. has_attached_file :image, :styles =&gt; { :large =&gt; ["330x230&gt;",:png], :medium =&gt; ["210x150&gt;",:png], :small =&gt; ["90x90&gt;",:png], :thumb =&gt; ["32x32&gt;", :png] }, :default_url =&gt; '/images/missing_image_:style.png', :storage =&gt; :s3, :bucket =&gt; 'iscomp', :s3_credentials =&gt; "#{RAILS_ROOT}/config/amazon_s3.yml", :path =&gt; "iscomp/:attachment/:style/:id.:extension" validates_attachment_presence :image validates_attachment_size :image, :less_than =&gt; 5.megabytes end </code></pre> <p>My issue is that because the images are stored on a second model, I am not able to access a default blank image when there are no images/records on the @item.item_image. If I had used paperclip directly on @item, Paperclip will return default image for me.</p> <p>What's the best way of doing this if I do not want to keep adding in if/unless statements whenever I call for a thumbnail?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload