update things

This commit is contained in:
zack 2024-10-26 22:38:41 -04:00
parent 984a193c5d
commit b2f2f57029
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
6 changed files with 27 additions and 9 deletions

View file

@ -35,7 +35,7 @@ defmodule Zoeyscomputer.Gists do
** (Ecto.NoResultsError)
"""
def get_gist!(id), do: Repo.get!(Gist, id)
def get_gist!(id), do: Repo.get!(Gist, id) |> Repo.preload([:author])
@doc """
Creates a gist.
@ -49,7 +49,11 @@ defmodule Zoeyscomputer.Gists do
{:error, %Ecto.Changeset{}}
"""
def create_gist(attrs \\ %{}) do
def create_gist(user, attrs \\ %{}) do
IO.puts("hereo")
attrs = Map.put(attrs, "author_id", user.id)
IO.inspect(attrs)
%Gist{}
|> Gist.changeset(attrs)
|> Repo.insert()