I have been doing some searching on the list and have found a potential
solution for displaying images from blob data, however, I am having some
issues getting it work.
My jpeg data is stored in a blob field in the same table as a person’s
information so using one of the available plugins may be difficult.
Here is my version of the suggested code:
@student = Student.find_by_id(params[:id])
@image = @student.id_picture
@filename = @student.first_name + “.jpg”
send_data @image, :filename => @filename,
:content_type => “image/jpeg”,
:disposition => ‘inline’
<%= image_tag url_for(:action => ‘student_photo’, :id => student) %>
When I try to load the page the pictures don’t display. I looked at the
logs and it appears that rails is trying to load static content from the
public/images directory. (with the filename being the student’s id and
the file extension “.png”) As a result I get a number of Routing
errors. Is there something wrong with my approach?