Is it possible to receive two parameters from defimpl to_param?

Hi all, I have the following routes:

get "/post/new", PostController, :new
post "/post", PostController, :create
resources "/:id", PostController, param: "slug", except: [:new, :create, :index]

I am using the :id parameter to make cleaner URLs. However, I now have to put @post.id all over my router helpers which may not be DRY enough. For example:

post_path(@conn, :show, @post.id, @post)

Is it possible to implement to_param in a way that I can get both the slug and the id inserted into the URL parameters? Or am I already doing this correctly?\

EDIT: just realized this might be a dumb question…

1 Like