diff --git a/lib/ketbin/pastes/paste.ex b/lib/ketbin/pastes/paste.ex index 8c6cd5f..6b73696 100644 --- a/lib/ketbin/pastes/paste.ex +++ b/lib/ketbin/pastes/paste.ex @@ -2,6 +2,8 @@ defmodule Ketbin.Pastes.Paste do use Ecto.Schema import Ecto.Changeset + @primary_key {:id, :string, autogenerate: false} + @derive {Phoenix.Param, key: :id} schema "pastes" do field :content, :string field :is_url, :boolean, default: false @@ -11,7 +13,7 @@ defmodule Ketbin.Pastes.Paste do @doc false def changeset(paste, attrs) do paste - |> cast(attrs, [:is_url, :content]) + |> cast(attrs, [:is_url, :content, :id]) |> validate_required([:is_url, :content]) end end diff --git a/lib/ketbin_web/controllers/paste_controller.ex b/lib/ketbin_web/controllers/paste_controller.ex index 4e6ec80..3b02224 100644 --- a/lib/ketbin_web/controllers/paste_controller.ex +++ b/lib/ketbin_web/controllers/paste_controller.ex @@ -15,6 +15,7 @@ defmodule KetbinWeb.PasteController do end def create(conn, %{"paste" => paste_params}) do + # paste_params = Map.put(paste_params, "id", s) case Pastes.create_paste(paste_params) do {:ok, paste} -> conn