lost o changes
This commit is contained in:
parent
3b86d545e4
commit
0e6da94e47
|
@ -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
|
||||
|
|
|
@ -19,6 +19,7 @@ defmodule Prototype.Content do
|
|||
"""
|
||||
def list_posts do
|
||||
Repo.all(Post)
|
||||
|> Repo.preload(:author)
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue