I’m trying to compare to bits of string in Elixir - if they’re equal then the if
block fires or the else
block should fire.
def show(conn, %{"id" => id}) do
Logger.info id
Logger.info "----------"
Logger.info conn.assigns.current_user
if conn.assigns.current_user == id do
professional = Repo.get!(Professional, id)
render(conn, "show.html", professional: professional)
else
conn
|> put_flash(:error, "You must be logged in for that!")
|> redirect(to: site_path(conn, :index))
|> halt()
end
In the above, Logger.info id
and Logger.info conn.assigns.current_user
both return the same thing, but the if
block is never entered.
What am I doing wrong?