views:

54

answers:

1

In my rails project i wanna use urls like this

mysite.com/controller/title/action

instead

mysite.com/controller/id/action

How can i now build a redirect to it, with the following line

redirect_to :action => "show"

it redirects to the id version, how do i have to customize the line to redirect to the url with the title?

A: 

This question provides some solutions to implement permalinks in Rails.

Simone Carletti
Hi, i don't know if this is exactly what i'm searching for. Permalink sounds very static. But the redirect that i posted is within a "update" action, it should simply show the just edited and updated record. But since i try to use seofriendly urls with titles instead ids i dont' succeed to redirect_to the just edited record to show, it redirects to the url with id. I guess there should be a more dynamically solution?
and
The id of the model is generated using the `to_param` method. If you follow the instructions in the post I showed you, you'll have Rails to dynamically generate the right path for you.
Simone Carletti
`to_param` is a model method, not a controller. Please make sure you read and you understand the links I posted before trying to write code.
Simone Carletti
@Simone i read it but it guess this is a bit to advanced at the moment, isn't there a much simpler solution, somehow like this? redirect_to :action => "show", :id => bookmarks.title
and