i''m storing images in database.
i have this action in controller:
def image
begin
item = StoredItem.find(:first, :conditions => {:id =>
params[:id]})
rescue
return
end
return if item.nil?
if item.image_binary.nil?
render :nothing => true
else
send_data(item.image_binary, :type => item.image_datatype,
:disposition => ''inline'') unless item.image_binary.nil?
end
end
and i have this code in view:
<%items.each do |item|%>
...
<%=image_tag(url_for(:action => :image, :id => item.id), :alt =>
item.name+'' image'', :size =>
''24x24'')%>
..
<%end>
everything works fine except that i have separate SELECT queries to
database on EACH loading image.
in view i''m iterating collection of "items", so i have all
neccessary
data and i don''t want to select it from database again. Is there any
way
to use "send_data" directly from image_tag or something similar?
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.