You're removing it somewhere, so stop removing it. Rails doesn't hide parameters or anything. Pretty much every rails site in existence uses some form of slug (usually an ID, but the implementation in the code is identical).
Rick Olson wrote the following on 04.06.2007 18:43 :
Keynan Pratt wrote:
post your routes please because I have a hunch. (all routes not just the ones you think are taking effect) and an example hash that you are passing to link_to
for grins, let's say that the default route: # Install the default route as the lowest priority. map.connect ':controller/:action/:id'
were being used to map this thing. Shouldn't there be a way to have the slug show up in the URL box?
In this forum for instance, navigating to this topic gives a URL of: Pointy haired boss request - turn off pretty url - Rails - Ruby-Forum
That 110551 is the slug. In my app as currently written, that would not be there. Am I doing something wrong? In a "normal" rails app where the default route is routing: http://www.mydomain.com/a/b/1
would that show up in the URL box after routing as: http://www.mydomain.com/a/b/1 ??? You're removing it somewhere, so stop removing it. Rails doesn't hide parameters or anything. Pretty much every rails site in existence uses some form of slug (usually an ID, but the implementation in the code is identical).
Just a 'hunch' of mine: do you use button_to or any other way of generating a form in the page to generate a button leading to this URL? Then it is probably the source of your problem, the "slug" as you call it is probably passed as a CGI parameter in the POST content, not in the URL.
If that's the case, the simplest solution would be to use link_to. If your routes aren't ok you'll have a "?slug=<slugvalue>" in the URL instead of the cleaner pretty URLs, if that's the case, as said previously, show us the routes. Without them we can only throw wild guesses around.
If you need the link to look like a button, just use CSS. Using a form to generate a link to a display page is bad practice: you are on the way to get nested forms (which are inherently broken). Only use forms to modify data.
Lionel.