   end
 
   def show(conn, %{"id" => id}) do
-    experiment = Experiment |> Repo.get_by(id: id)
+    experiment = Experiment |> Repo.get(id)
 
     case experiment do
       nil ->


      case Map.fetch(experiment_params, "participants_ids") do
        {:ok, participants_ids} ->
          attach_participants_to_experiment(participants_ids, experiment)
      end

      conn

  end

  def update(conn, %{"id" => id, "experiment" => experiment_params}) do
    experiment = Experiment |> Repo.get!(id)

    experiment_changeset = Experiment.changeset(experiment, experiment_params)

    if experiment_changeset.valid? do
      participants_ids = experiment_params |> Map.fetch!("participants_ids")

      experiment = Repo.update!(experiment_changeset)

      case update_participants_in_experiment(participants_ids, experiment.id) do
        {:ok, _} ->
          attached_participants = fetch_participants(experiment)

          conn
          |> put_status(:created)
          |> render("success.json", experiment: Map.put(experiment, :attached_participants, attached_participants))
      end
    else
      conn
      |> put_status(:unprocessable_entity)
