your web server cannot bypass Rails and efficiently serve
the> image!
I admit that I am by no means a database expert but I implemented this
about two weeks ago and have had no problems (so far).
Here is what I did.
First my field in the adatabase I declared as a bytea (Byte Array). I
tried using other field types, such as OID, with no success.
View:
<% form_remote_tag( :url => {:action => ''uploadFile'',
:account_id => @account.id}, :update => ''image_div'' )
do -%>
<p><label for="image_img">Select a File:</label>
<%= file_field ''image'', ''img''
%></p>
<%= submit_tag "Upload" %>
<% end -%>
:controller
@image = Image.new
@image.img = File.open(params[:image][:img] , "rb").read
@image.save
I am not sure what purpose the "rb" serves since I had to look long
and
hard for a working example, and in the end I think I was relegated to
trying different approaching from several examples.
:View to render the image - First get image via simple find
<%= image_tag url_for(:action => ''image'', :account_id
=> @account.id)
%>
Like I said this example renders the image just fine, but I would be
very interested to hear what possible problems there are with this
appraoch as I have done this for a project at work and it is about a
month away from going live. Thanks,
-S
--
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
-~----------~----~----~----~------~----~------~--~---