How to debug data inside of conn.assigns?

I have this function inside of my controller and I’m trying to figure out 1) what data is available to me inside of conn.assigns and 2) debug variables.

  def sample(conn, _params) do
    test = conn.assigns.test_data
    render(conn, "sample.html", test_data: test)
  end

I’m new to a Phoenix codebase so I’m trying to understand what is already available to me.

I’ve already tried:
IO.puts(conn.assigns.test_data)
IO.puts(conn.assigns)
IO.puts(test)
IO.inspect(conn.assigns.test_data)

That shows you what data is in your test_data. Just try IO.inspect(conn.assigns) or even IO.inspect(conn) to get a better idea of what is available. Also consider , pretty: true to make it easier to read.

5 Likes