lost o changes

This commit is contained in:
Eric S. Londres 2023-05-04 20:41:30 -04:00
parent 3b86d545e4
commit 0e6da94e47
Signed by: slondr
GPG Key ID: A2D25B4D5CB970E4
5 changed files with 5 additions and 4 deletions

View File

@ -7,7 +7,7 @@ defmodule Prototype.Accounts.User do
field :password, :string, virtual: true, redact: true
field :hashed_password, :string, redact: true
field :confirmed_at, :naive_datetime
has_many :posts, Content.Post
has_many :posts, Prototype.Content.Post, foreign_key: :author_id
timestamps()
end

View File

@ -19,6 +19,7 @@ defmodule Prototype.Content do
"""
def list_posts do
Repo.all(Post)
|> Repo.preload(:author)
end
@doc """

View File

@ -5,7 +5,7 @@ defmodule Prototype.Content.Post do
schema "posts" do
field :body, :string
field :title, :string
belongs_to :user, Accounts.User, foreign_key: :author_id
belongs_to :author, Prototype.Accounts.User, foreign_key: :author_id
timestamps()
end

View File

@ -8,8 +8,8 @@
</.header>
<.table id="posts" rows={@posts} row_click={&JS.navigate(~p"/posts/#{&1}")}>
<:col :let={post} label="Author"><%= post.author.email %></:col>
<:col :let={post} label="Title"><%= post.title %></:col>
<:col :let={post} label="Body"><%= post.body %></:col>
<:action :let={post}>
<div class="sr-only">
<.link navigate={~p"/posts/#{post}"}>Show</.link>

View File

@ -3,7 +3,7 @@
Oops, something went wrong! Please check the errors below.
</.error>
<.input field={f[:title]} type="text" label="Title" />
<.input field={f[:body]} type="text" label="Body" />
<.input field={f[:body]} type="textarea" label="Body" />
<:actions>
<.button>Save Post</.button>
</:actions>