Hello,
I have problem in displaying image from database, please help me how to
display my image.
DATABASE DETAIL
--------------------
(I not create file name field to save original file name to database)
employee_name, type data -> varchar
...
face_pict - type data -> bolb
pict_content - type data -> varchar
--------------------------------
display_image_controller.rb
--------------------------------
class DisplayImageController < ApplicationController
def employee_face
@employees = Employee.find(params[:id])
send_data(@employees.face_pict, :type => @employees.pict_content,
:disposition => "inline")
end
end
--------------------------------
employee.rhtml
--------------------------------
...
<%= image_tag("/display_image/employee_face?id="+employee.id.to_s,
:alt
=> employee.name, :class => "fix_pict") %>
...
------------
THE PROBLEM
------------
I tried the script above for displaying image, when I run it in
development server, the image is displayed properly. But when I deploy
it and run it in production server, the image can not be displayed
without error message.
My Analysis:
-----------
1. I check use Firefox and Opera, the image''s size of file is read
correctly.
2. My saved picture content is image/jpeg. I check production.log i got
this :
..................................................................
Processing DisplayImageController#employee (for xx.91.x.210 at
2008-02-18 03:05:02) [GET]
Session ID: beec19ee523ea0e8d3838da9800bb48d
Parameters: {"action"=>"employee_face",
"id"=>"6.png",
"controller"=>"display_image"}
Sending data
Completed in 0.00153 (652 reqs/sec) | Rendering: 0.00003 (2%) | DB:
0.00043 (27%) | 200 OK
[http://mydomain.com/display_image/employee_face?id=6.png]
..................................................................
3. I run this link :
http://mydomain.com/display_image/employee_face?id=6 (without .png) and
my image still can not be displayed. Then i go to production.log again
and see this new written :
..................................................................
Processing DisplayImageController#employee (for xx.91.x.210 at
2008-02-18 03:07:12) [GET]
Session ID: c040263c1e0bb218297918330c82ba14
Parameters: {"action"=>"employee_face",
"id"=>"6",
"controller"=>"display_image"}
Sending data
Completed in 0.00180 (555 reqs/sec) | Rendering: 0.00003 (1%) | DB:
0.00063 (34%) | 200 OK
[http://mydomain.com/display_image/employee_face?id=6]
..................................................................
4. I tried another script in my view
--------------------------------
modified --> employee.rhtml
--------------------------------
...
<image class = "fix_pict"
src="/display_image/employee_face?id=<%employee.id %> ">
...
And after i deployed it using capistrano, the same thing is happened
again (picture still can not be displayed). Please help me what should
i do to display my image from database. Thank you very much.
Riand
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---