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: (controller) def student_image @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'' end (view) <%= 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? Thanks, Jake -- 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 -~----------~----~----~----~------~----~------~--~---
get the plugin file column it so kick db storages a$$ -- 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 -~----------~----~----~----~------~----~------~--~---
Jake Schutz wrote:> 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: > > (controller) > def student_image > @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'' > end > > (view) > <%= 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? > > Thanks, > Jakehey, i''m wondering about this line: @image = @student.id_picture is this @student.id_picture the same as @student.data? -- 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 -~----------~----~----~----~------~----~------~--~---
Jennifer Lindner wrote:>> (controller) >> def student_image >> @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'' >> end >> >> (view) >> <%= image_tag url_for(:action => ''student_photo'', :id => student) %> >>> > > hey, i''m wondering about this line: > @image = @student.id_picture > > is this @student.id_picture the same as @student.data?Yes Jennifer, the "id_picture" field contains the blob data for a students id badge photo. -Jake -- 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 -~----------~----~----~----~------~----~------~--~---
> Yes Jennifer, the "id_picture" field contains the blob data for a > students id badge photo. > > -Jakeis the action name student_photo or student_image? maybe that''s the issue? -- 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 -~----------~----~----~----~------~----~------~--~---
Jennifer Lindner wrote:>> Yes Jennifer, the "id_picture" field contains the blob data for a >> students id badge photo. >> >> -Jake > > is the action name student_photo or student_image? maybe that''s the > issue?Sorry, that was a typo in my post (should have cut/pasted). It should read: <%= image_tag url_for(:action => ''student_image'', :id => student) %> It seems like the image_tag helper is just taking the url that was generated by url_for and just trying to serve that up as static content rather than receiving the response from the send_data call. The logs first show: DEPRECATION WARNING: You''ve called image_path with a source that doesn''t include an extension. In Rails 2.0, that will not result in .png automatically being appended. So you should call image_path(''/advisor/student_image/65757.png'') and then the routing errors appear because the static content couldn''t be found. -- 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 -~----------~----~----~----~------~----~------~--~---
Jake Schutz wrote:> Jennifer Lindner wrote: >>> Yes Jennifer, the "id_picture" field contains the blob data for a >>> students id badge photo. >>> >>> -Jake >> >> is the action name student_photo or student_image? maybe that''s the >> issue? > > Sorry, that was a typo in my post (should have cut/pasted). It should > read: > > <%= image_tag url_for(:action => ''student_image'', :id => student) %> > > It seems like the image_tag helper is just taking the url that was > generated by url_for and just trying to serve that up as static content > rather than receiving the response from the send_data call. > > The logs first show: > DEPRECATION WARNING: You''ve called image_path with a source that doesn''t > include an extension. In Rails 2.0, that will not result in .png > automatically being appended. So you should call > image_path(''/advisor/student_image/65757.png'') > > and then the routing errors appear because the static content couldn''t > be found.i have almost the same thing working...now i''m wondering if it''s your :id; should that be student.id? that''s working for me: <%= image_tag(url_for(:action => ''photo'', :id => photo.id), :border => 0)%> -- 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 -~----------~----~----~----~------~----~------~--~---
> > i have almost the same thing working...now i''m wondering if it''s your > :id; should that be student.id? that''s working for me: > <%= image_tag(url_for(:action => ''photo'', :id => photo.id), :border => > 0)%>I have tried a few more things: Simplifying my student_image method to: def student_image @student = Student.find_by_id(params[:id]) send_data(@student.id_picture, :content_type => "image/jpeg") end and disambiguating my view (to look more like yours, as well as changing student to student.id) <%= image_tag(url_for(:action => ''student_image'', :id => student.id), :border => 0) %> I''m still getting the same results. The action doesn''t seem to be getting called. Are you running Rails 1.2.1? -- 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 -~----------~----~----~----~------~----~------~--~---
Jake Schutz wrote:> >> >> i have almost the same thing working...now i''m wondering if it''s your >> :id; should that be student.id? that''s working for me: >> <%= image_tag(url_for(:action => ''photo'', :id => photo.id), :border => >> 0)%> > > I have tried a few more things: > > Simplifying my student_image method to: > > def student_image > @student = Student.find_by_id(params[:id]) > send_data(@student.id_picture, :content_type => "image/jpeg") > end > > and disambiguating my view (to look more like yours, as well as changing > student to student.id) > > <%= image_tag(url_for(:action => ''student_image'', :id => student.id), > :border => 0) %> > > I''m still getting the same results. The action doesn''t seem to be > getting called. Are you running Rails 1.2.1?no, i''m not -- not until i can overcome my daunting obstacles in 1.8! one thing i forgot which is important. i''m doing these image tags in a loop: for photo in @photo_collection (which is just a find(:all)). so photo.id is not @photo.id. i''m sorry, i should have realized that in my last post. do you have any ideas for trying to send DOM objects to a controller as parameters, like say a string array of ids? ;-) -- 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 -~----------~----~----~----~------~----~------~--~---
> no, i''m not -- not until i can overcome my daunting obstacles in 1.8! > one thing i forgot which is important. i''m doing these image tags in a > loop: for photo in @photo_collection (which is just a find(:all)). > > so photo.id is not @photo.id. i''m sorry, i should have realized that in > my last post. > > do you have any ideas for trying to send DOM objects to a controller as > parameters, like say a string array of ids? ;-)That''s exactly what I''m doing. I have a collection of student objects who each have a photo. This means I have to do two lookups one to get the student list and one to get their photo while looping through the students. I''m still confused why I can''t get this to work. I wish I had more options for dealing with the blob field, however, this is getting propagated from outside of my rails app. Has anybody else been able to use this to load blob data into a view (as an image) with Rails 1.2.1? -- 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 -~----------~----~----~----~------~----~------~--~---
Jake Schutz wrote:> >> no, i''m not -- not until i can overcome my daunting obstacles in 1.8! >> one thing i forgot which is important. i''m doing these image tags in a >> loop: for photo in @photo_collection (which is just a find(:all)). >> >> so photo.id is not @photo.id. i''m sorry, i should have realized that in >> my last post. >> >> do you have any ideas for trying to send DOM objects to a controller as >> parameters, like say a string array of ids? ;-) > > That''s exactly what I''m doing. I have a collection of student objects > who each have a photo. This means I have to do two lookups one to get > the student list and one to get their photo while looping through the > students. I''m still confused why I can''t get this to work. > > I wish I had more options for dealing with the blob field, however, this > is getting propagated from outside of my rails app. > > Has anybody else been able to use this to load blob data into a view (as > an image) with Rails 1.2.1?hey best of luck -- i''m pretty new to this. have you seen this guy''s site? he imports images into db via fixtures & then displays them :http://www.realityforge.org/articles/2006/04/21/eyelook-rails-photo-gallery maybe he could/would be helpful cheers -- 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 -~----------~----~----~----~------~----~------~--~---