Topic: REST urls on rails...

Normally the REST urls are as http://localhost/project/
Can we change these urls such that it appears as http://localhost/project/{}?
i.e, instead of id can we access a resource by its name?


Re: REST urls on rails...

Yep, you can create a field in your table called permalink and then create an action in your project model called to_param

def to_param

Just make sure in you're controller that you don't try to grab by params[:id].  Instead you'll have to use something like this instead:

@project = Project.find_by_permalink(params[:id])

Re: REST urls on rails...

Thanks for the reply.
But I want to change the URLs. Instead of ids in REST url , can we show name?