Вопрос

First sorry for my english i am french

I am using Frindly_id gem to generate clean url and it work just fine i still have a problem, for example let's say i have a user with user_id=1 and a full_name = = "olivier logaro" so when i go to this user profile i have this url localhost:3000/profile/olivier-logaro so that what i want but the problem is when i go to localhost:3000/profile/1 it will give me the profile of olivier logaro. So what i want is to have acces to the users profile whith just the first url and if i try the second url i will have a error this url doesn't exit

Это было полезно?

Решение

The solution is each time you query on a rails 3 app use:

Profile.find_by_slug(params[:id])

if you use a rails 4 app

Profile.find_by slug: params[:id]

Другие советы

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top