Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

Pry in Elixir Phoenix

One of my favorite debugging tools in Ruby is Pry, so I wanted to find something similar to use when developing Phoenix applications. Thankfully Elixir has pry built in!

To use it in Phoenix, simply include this line wherever you want to pry:

require IEx; IEx.pry

I then had to start my server in an IEx session to get the pry to work (I’ve read this will be fixed soon):

iex -S mix phoenix.server

When you hit that function, you will be asked to confirm that you want to Pry

Request to pry #PID<0.331.0> at web/controllers/user_controller.ex:7. Allow? [Yn]

Confirm by typing Y and you will be good to pry away!

pry(1)>
Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.