     end
   end
 
-  def delete(conn, %{"id" => id}) do
-    tag = Repo.get!(Tag, id)
+  def delete(conn, %{"id" => _}) do
+    tag = conn.assigns[:tag]
 
     # Here we use delete! (with a bang) because we expect
     # it to always work (and if it does not, it will raise).


  plug Guardian.Plug.EnsureAuthenticated, %{handler: Core.Auth} when action in [:create, :update, :delete]
  plug Core.BodyParams, name: "tag"

  def index(conn, _params) do
    tags = Repo.all(Tag)


    send_resp(conn, :no_content, "")
  end

  defp find(conn = %Plug.Conn{params: %{"id" => id}}, _opts) do
    case Repo.get(Tag, id) do
      {:ok, tag} ->
        conn
        |> assign(:tag, tag)

      _ ->
        conn
        |> put_status(:not_found)
        |> render(Core.ErrorView, "404.json", %{})
        |> halt()
    end
  end
end
