0

I got my create, update and show forms working for a single entity. One of the fields is an image file that I am entering using the multipart attribute in the form. My question is how do I show the image attribute in the show form.

<tr>
 <th>Photo</th>
 <td><%= @teacher.photo %></td>
</tr>

The photo attribute is of binary type in the table definition.

create_table :teachers do |t|

   t.string :firstname, null: false
   t.string :lastname, null: false
   t.string :email, null: false
   t.string :cellphone
   t.string :username, null: false
   t.string :password_digest, null: false
   t.string :addr_streetno
   t.integer :addr_aptno
   t.string :addr_city
   t.string :addr_state
   t.integer :addr_zip
   t.binary :photo, :limit => 0.5.megabyte

   t.timestamps
end 
gvermag
  • 389
  • 1
  • 5
  • 12
  • [Store images in the database](http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay)? – manu29.d May 21 '14 at 06:55

1 Answers1

2

we can display images as Thumbnails by using carrier wave gem

<%= image_tag @teacher.photo_url(:thumb) if @teacher.photo? %>
Pavan
  • 33,316
  • 7
  • 50
  • 76
vel pradeep.MS
  • 584
  • 5
  • 7