Luigi
(Luigi)
October 11, 2007, 5:37pm
1
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!
Luigi
(Luigi)
October 11, 2007, 9:32pm
2
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
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?
rab
(Rob Biedenharn)
October 11, 2007, 11:39pm
5
Look at the Rails doc for "send_data" (or send_file)
-Rob
Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
Luigi
(Luigi)
October 12, 2007, 7:35am
6
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!
In that case, look at acts_as_sluggable. Or create a route that
includes the picture name.
Luigi
(Luigi)
October 12, 2007, 11:21pm
8
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!
Luigi
(Luigi)
October 13, 2007, 10:35am
9
But is this way slower than the search by the sample id?
Luigi
(Luigi)
October 14, 2007, 3:34pm
10
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!