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

    end
  end

  def show(conn, %{"id" => id}) do
    case Repo.get(Annotation, id) do
      nil ->
        conn
        |> put_status(:not_found)
        |> render(Core.ErrorView, "404.json", %{})
      annotation ->
        annotation = Repo.preload(annotation, :annotation_tags)
        conn
        |> render("show.json", annotation: annotation)
    end
  end

  def update(conn, %{"id" => id, "annotation" => annotation_params}) do
    annotation = Repo.get!(Annotation, id)
    changeset = Annotation.changeset(annotation, annotation_params)

    case Repo.update(changeset) do

  use Core.Web, :controller
  alias Core.Annotation

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

  def index(conn, _params) do
    annotations = Repo.all(Annotation)
