-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I would like to extract an image BLOB from my database and display it alongside some other information on my ''edit'' page. I read the information here http://wiki.rubyonrails.com/rails/show/HowtoUploadFiles and that was really helpful. However, it still isn''t clear to me how I would get access to the image in my views if I use send_data. My naive reading of send_data is that you get a page with only the image on it. Hopefully I just misunderstand something here, because the next option in my queue is to try writing images out to public/images as temporary files and I''d really like to avoid doing that ;) So, can I use send_data in conjunction with a view to display images in my database? Thanks in advance, Patrick - -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Patrick J. Franz patrick-LkoapWg8zFbQT0dZR+AlfA@public.gmane.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCLS0inBL/CxPCaScRAjIvAJ4tXe5dy+f4Z9YdYytgYl5i5SV9MACfSqjK wU4Qdz4+MdA2J404BLFf2gE=AMFs -----END PGP SIGNATURE-----
On Mon, 07 Mar 2005 20:42:10 -0800, Patrick Franz -- ML <patrick-LkoapWg8zFbQT0dZR+AlfA@public.gmane.org> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I would like to extract an image BLOB from my database and display it > alongside some other information on my ''edit'' page. I read the > information here > > http://wiki.rubyonrails.com/rails/show/HowtoUploadFiles > > and that was really helpful. > > However, it still isn''t clear to me how I would get access to the image > in my views if I use send_data. My naive reading of send_data is that > you get a page with only the image on it. Hopefully I just misunderstand > something here, because the next option in my queue is to try writing > images out to public/images as temporary files and I''d really like to > avoid doing that ;) So, can I use send_data in conjunction with a view > to display images in my database?I''m not sure I follow what you''re trying, just remember there are two parts to displaying an image on a page: * The HTML to display it (<img src="" />) * The image itself http://www.example.com/image/5 So you probably want a controller (say ImageController) which has an action show. This is what will do the send_data @blob. Then you want your views in *other controllers* to do something like: <img src="<%= url_for :controller => "image", :id=>@whatever.image_id, :action=>"show" %>" /> Is that what you''re looking for?> Thanks in advance, > Patrick > > - -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Patrick J. Franz > > patrick-LkoapWg8zFbQT0dZR+AlfA@public.gmane.org > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.0 (MingW32) > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFCLS0inBL/CxPCaScRAjIvAJ4tXe5dy+f4Z9YdYytgYl5i5SV9MACfSqjK > wU4Qdz4+MdA2J404BLFf2gE> =AMFs > -----END PGP SIGNATURE----- > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Michael Koziarski wrote: |> I''m not sure I follow what you''re trying, just remember there are two |> parts to displaying an image on a page: | |> * The HTML to display it (<img src="" />) |> * The image itself http://www.example.com/image/5 Right. |> So you probably want a controller (say ImageController) which has an |> action show. This is what will do the send_data @blob. Then you want |> your views in *other controllers* to do something like: |> <img src="<%= url_for :controller => "image", :id=>@whatever.image_id, |> :action=>"show" %>" /> | |> Is that what you''re looking for? I think so. I didn''t even consider creating a separate controller just to handle the images, but I can see how that will work now. Thank you. Best Regards, Patrick - -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Patrick J. Franz patrick-LkoapWg8zFbQT0dZR+AlfA@public.gmane.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCLTAEnBL/CxPCaScRAmshAJ4/+PbDg4crU7jOldm9ARnythctiQCgq0vR pFEpJXfKW/Gfh3GRlwuEDBw=GtJu -----END PGP SIGNATURE-----
On 08/03/2005, at 3:42 PM, Patrick Franz -- ML wrote:> I would like to extract an image BLOB from my database and display it > alongside some other information on my ''edit'' page.Might want to check out: http://thread.gmane.org/gmane.comp.lang.ruby.rails/3392 - tim lucas