fix(models): prevent IDs being empty while inserting
Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
parent
99ad54cf68
commit
d818c7033a
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user