The :id parameter in routing is just a placeholder and can be anything: from a numeric identifier to a bullet.
You just need to pass the correct value
article_path(id: @article.slug)
and extract the article using the appropriate method
Article.find_by!(slug: params[:id])
If you prefer, you can also override to_param for the Article model to return slug so you can use
article_path(@article)
and automatically slug will be assigned to :id .
source share