Hi, in my ruby application I manage a MySQL db. The url are generated by the classic command line link_to or url_for. For image I use the command: <img src="<%= url_for(:action=>"picture", :id=>@pictures.id)-%>" .... so the URL generated is: /view/picture/500 I would like to generate an URL like this one: /view/picture/500/neroburning.jpg Can you help me? Thank you very much! --~--~---------~--~----~------------~-------~--~----~ 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 don''t see the point to use url_for in image :S:S Take a look at image_tag :D image_tag("icon.png") # => <img src="/images/icon.png" alt="Icon" /> image_tag("icon.png", :size => "16x10", :alt => "Edit Entry") # => <img src="/images/icon.png" width="16" height="10" alt="Edit Entry" /> image_tag("/icons/icon.gif", :size => "16x16") # => <img src="/icons/icon.gif" width="16" height="16" alt="Icon" /> -- 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 -~----------~----~----~----~------~----~------~--~---
Hi, thank for your answer but I need to know the answer to my question because the images of my site load from the db! Can you help me to write: /picture/500-neroburning.jpg or /view/picture/500/neroburning.jpg instead of the simple: /view/picture/500 Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/11/07, Luigi <softwarewin.net-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > thank for your answer but I need to know the answer to my question > because the images of my site load from the db! > Can you help me to write: > > /picture/500-neroburning.jpgGoogle for acts_as_sluggable --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/11/07, Bob Showalter <showaltb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 10/11/07, Luigi <softwarewin.net-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > thank for your answer but I need to know the answer to my question > > because the images of my site load from the db! > > Can you help me to write: > > > > /picture/500-neroburning.jpg > > Google for acts_as_sluggable >Oh wait a minute. Are you wanting the .jpg so the browser will treat it as an image? If so, you need to be setting the correct content type on your response. What does your controller action look like? How are you sending the image? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 11, 2007, at 7:29 PM, Bob Showalter wrote:> On 10/11/07, Bob Showalter <showaltb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 10/11/07, Luigi <softwarewin.net-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> Hi, >>> thank for your answer but I need to know the answer to my question >>> because the images of my site load from the db! >>> Can you help me to write: >>> >>> /picture/500-neroburning.jpg >> >> Google for acts_as_sluggable >> > > Oh wait a minute. Are you wanting the .jpg so the browser will treat > it as an image? If so, you need to be setting the correct content type > on your response. What does your controller action look like? How are > you sending the image?Look at the Rails doc for "send_data" (or send_file) -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
Hi, my problem isn''t the loading of image from db. I already use send_data etc... and the browser works properly. The matter is that the compiling of url of ruby isn''t friendly for the search engine spider because it is written like this: /view/picture/500 I would like to customize the url, also those not referring to images, like this: /view/picture/500/neroburning.jpg or /picture/500-neroburning.jpg The site is softwarewin.net. Thank you! On 12 Ott, 01:39, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On Oct 11, 2007, at 7:29 PM, Bob Showalter wrote: > > > > > > > On 10/11/07, Bob Showalter <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 10/11/07, Luigi <softwarewin....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>> Hi, > >>> thank for your answer but I need to know the answer to my question > >>> because the images of my site load from the db! > >>> Can you help me to write: > > >>> /picture/500-neroburning.jpg > > >> Google for acts_as_sluggable > > > Oh wait a minute. Are you wanting the .jpg so the browser will treat > > it as an image? If so, you need to be setting the correct content type > > on your response. What does your controller action look like? How are > > you sending the image? > > Look at the Rails doc for "send_data" (or send_file) > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > smime.p7s > 3KScarica- Nascondi testo tra virgolette - > > - Mostra testo tra virgolette ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/12/07, Luigi <softwarewin.net-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > my problem isn''t the loading of image from db. > I already use send_data etc... and the browser works properly. > The matter is that the compiling of url of ruby isn''t friendly for the > search engine spider because it is written like this: > > /view/picture/500In that case, look at acts_as_sluggable. Or create a route that includes the picture name. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, I had written a site in ruby....but I don''t know how to use the plugins.... How can I use acts_as_sluggable on my webhosting? Thank you very much! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Luigi wrote:> I would like to customize the url, also those not referring to images, > like this: > > /view/picture/500/neroburning.jpg > > or > > /picture/500-neroburning.jpgThe *easiest* way is to overwrite the to_param method in your model. Example: class Image def to_param %{#{ id }-#{ filename }} end end So you''d get something like this in your URL: 23-neroburning.jpg -- 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 -~----------~----~----~----~------~----~------~--~---
Daniel Waite wrote:> Luigi wrote: >> I would like to customize the url, also those not referring to images, >> like this: >> >> /view/picture/500/neroburning.jpg >> >> or >> >> /picture/500-neroburning.jpg > > The *easiest* way is to overwrite the to_param method in your model. > Example: > > class Image > > def to_param > %{#{ id }-#{ filename }} > end > > end > > So you''d get something like this in your URL: > > 23-neroburning.jpgNote that you must pass in the object itself when generating links: link_to(image_tag(...), :action => ''...'', :id => image) # Good link_to(image_tag(...), :action => ''...'', :id => image.id) # Bad -- 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 -~----------~----~----~----~------~----~------~--~---
But is this way slower than the search by the sample id? --~--~---------~--~----~------------~-------~--~----~ 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''m going on solution: to do other similar modify I have used the routes.rb: map.software ''view/:id/software/:title'', :controller=>''view'', :action=>''software'' in view.rhtml I''m using: href="< %=software_url(:id=>guide.id,:title=>guide.title.split.join("-"))-%>" that generate: ..../view/92/software/Spyware-Doctor so I can introduce the name of the software separated by "/". This way will work also for "picture". The fantastic thing is that routes.rb works also if I write: map.software ''view/:id/software/:title.html'', :controller=>''view'', :action=>''software'' so the generated url becames: ..../view/92/software/Spyware-Doctor.html It''s great! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---