     changeset = Question.changeset(%Question{}, question_params)
 
     case insert_question_and_tags(changeset) do
-      {:ok, question, tags} ->
+      {:ok, question} ->
         question = question
-        |> Map.put(:tags, tags)
+        |> Repo.preload(:question_tags)
 
         conn
         |> put_status(:created)


  defp insert_question_and_tags(changeset) do
    Repo.transaction(fn ->
      case (Repo.insert(changeset) |> insert_tags(changeset.tags)) do
        {:error, changeset} ->
          Repo.rollback(changeset)
        {:ok, question, tags} ->
          {:ok, question, tags}
      end
    end)
  end

  defp insert_tags({:error, changeset}, _), do: {:error, changeset}
  defp insert_tags({:ok, question}, tags_id) do
    tag_id_to_changeset = fn tag ->
      QuestionTag.changeset(%{"tag_id" => tag.id,
                              "question_id" => question.id,
                              "required" => tag.required})
    end

    insert_changeset = fn


  def update(conn, question_params) do
    question = conn.assigns[:question]
    |> Repo.preload(:question_tags)

    changeset = Question.changeset(
      Map.merge(question, %{tags: question.question_tags}),
      question_params)

    case Repo.update(changeset) do
      {:ok, question} ->
