Now that we have slugs for out posts, how do we use them? Elixir protocols are an amazing way to build polymorphic interfaces and since ‘Phoenix.Param’ the module that converts data structures into URL parameters is a protocol we can take advantage of this and create our own implementation.

We’ll go to the bottom of post.ex and define our custom implementation for the ‘post’ module. Now we’ll define the ‘to_param’ function and pattern match to get our ‘slug’. And then we’ll simply return the ‘slug’ to use.