Route a name to an id?

i have a database setup with an id and a field called uniquename

say for example my db looks like this:

id uniquename
1 pizza
2 salad

at the moment the routing works as follows:

domain.com/recipe/show/2

instead i’d like it to route from:

domain.com/recipe/show/salad

any ideas?

Andrew Kendall wrote:

i have a database setup with an id and a field called uniquename

say for example my db looks like this:

id uniquename
1 pizza
2 salad

at the moment the routing works as follows:

domain.com/recipe/show/2

instead i’d like it to route from:

domain.com/recipe/show/salad

any ideas?

You can do this as-is. Just use the params[:id] differently. i.e.,
search for it in the database:

item = Items.find_by_uniquename(params[:id])

I’m a newbie answering a question, so take this with a grain of salt.

Jake