Topic: REST urls on rails...

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

Regards,
Kalyan.C

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
  permalink
end

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?