     end
   end
 
-  def delete(conn, %{"id" => id}) do
-    question = Repo.get!(Question, id)
+  def delete(conn, %{"id" => _}) do
+    question = conn.assigns[:question]
 
     # 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: "question"

  def index(conn, _params) do
    questions = Repo.all(Question)

    end
  end

  def show(conn, %{"id" => _}) do
    question = conn.assigns[:question]
    render(conn, "show.json", question: question)
  end

  def update(conn, %{"id" => _, "question" => question_params}) do
    question = conn.assigns[:question]
    changeset = Question.changeset(question, question_params)

    case Repo.update(changeset) do
