ActiveStorage Cook Book

Model:
 
class Image < ApplicationRecord
  has_one_attached :picture
end
 
Check if pictured is attached before displaying
 
<p>
  <strong>picture:</strong>
  <%= image_tag @image.picture if @image.picture.attached? %>
</p>
 
Check if pictured is attached before displaying with variant
 
<td>
  <% if image.picture.attached? %>
    <%= image_tag image.picture.variant(resize: "100x100") %>
  <% end %>
</td>

North New Jersey Office

Kinnelon, NJ

Philadelphia Office

Media, PA

office Hours

Mon - Fri : 8am to 6pm

Social Media