I''m saving images to a database when uploaded, and I''m trying to display the images back out in the views. I can get this to work, but it''s not very consistent... Here''s what I''m doing: <%= image_tag(url_for(:controller=>"picture", :action=>"show", :id=>@house.picture_id),:alt=>"")%> Right off, it doesn''t show the images. But eventually it does, like if I interact with the database again, or re-upload an image, they all seem to work. This seems to be my problem, when right-clicking on the properties of the image, this is the url: /picture/show/1.png? And it should be: /picture/show/1 How come this is appending ".png?" to the end of my image? Should this be doing this? Please help, as the images HAVE to show up, and I''ve tried everything I can think of. Thanks! -- 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 -~----------~----~----~----~------~----~------~--~---
ryan wrote:> I''m saving images to a database when uploaded, and I''m trying to display > the images back out in the views. I can get this to work, but it''s not > very consistent... Here''s what I''m doing: > > <%= image_tag(url_for(:controller=>"picture", :action=>"show", > :id=>@house.picture_id),:alt=>"")%> > > Right off, it doesn''t show the images. But eventually it does, like if > I interact with the database again, or re-upload an image, they all seem > to work. This seems to be my problem, when right-clicking on the > properties of the image, this is the url: > > /picture/show/1.png? > > And it should be: > > /picture/show/1 > > How come this is appending ".png?" to the end of my image? Should this > be doing this? Please help, as the images HAVE to show up, and I''ve > tried everything I can think of. Thanks!The image_tag helper will append .png if there is no extension in the url since it thinks all of your image should be files. The best way around this is create a custom route that looks like an image file. map.picture ''pictures/show/:id/imge.jpg'', :controller => :pictures, :action => ''show or on edge rails: map.picture ''pictures/show/:id.jpg'' :controller => :pictures, :action => ''show Then you can: <%= image_tag(picture_url(:id => 1)) %> And all should be dandy. Also look into the Flex Image plugin as it will make the reading and writing of image to your database super easy. http://www.agilewebdevelopment.com/plugins/fleximage -- 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 -~----------~----~----~----~------~----~------~--~---
Is there any way to emulate that :id.jpg routing functionality without edge rails? I can''t justify edge for only that, but would really like .jpg extensions on the images. Thanks, Chad On Nov 20, 11:18 pm, Alex Wayne <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> ryan wrote: > > I''m saving images to a database when uploaded, and I''m trying to display > > the images back out in the views. I can get this to work, but it''s not > > very consistent... Here''s what I''m doing: > > > <%= image_tag(url_for(:controller=>"picture", :action=>"show", > > :id=>@house.picture_id),:alt=>"")%> > > > Right off, it doesn''t show the images. But eventually it does, like if > > I interact with the database again, or re-upload an image, they all seem > > to work. This seems to be my problem, when right-clicking on the > > properties of the image, this is the url: > > > /picture/show/1.png? > > > And it should be: > > > /picture/show/1 > > > How come this is appending ".png?" to the end of my image? Should this > > be doing this? Please help, as the images HAVE to show up, and I''ve > > tried everything I can think of. Thanks!The image_tag helper will append .pngif there is no extension in the > url since it thinks all of your image should be files. > > The best way around this is create a custom route that looks like an > image file. > > map.picture ''pictures/show/:id/imge.jpg'', > :controller => :pictures, :action => ''show > > or on edge rails: > > map.picture ''pictures/show/:id.jpg'' > :controller => :pictures, :action => ''show > > Then you can: > > <%= image_tag(picture_url(:id => 1)) %> > > And all should be dandy. > > Also look into theFlexImage plugin as it will make the reading and > writing of image to your database super easy. > > http://www.agilewebdevelopment.com/plugins/fleximage > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Chad wrote:> Is there any way to emulate that :id.jpg routing functionality without > edge rails? I can''t justify edge for only that, but would really like > .jpg extensions on the images. > > Thanks, > Chad > > > > On Nov 20, 11:18 pm, Alex Wayne <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>You can do the first option I suggested: map.picture ''pictures/show/:id/image.jpg'', :controller => :pictures, :action => ''show it will just give urls like: /pictures/show/1/image.jpg instead my second example on edge: /pictures/show/1.jpg It works without edge rails fine, its just not quite as concise. -- 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 -~----------~----~----~----~------~----~------~--~---