1
の子どもたちのインデックステンプレートをレンダリングします。ユーザーに電子メールがある場合は、User
show
にEmail
index
テンプレートを表示します。ここでは、コードは次のようになります。は、私が<code>User</code>と<code>Email</code>足場(<code>user</code><code>has_many</code><code>emails</code>)を持っている親のショーテンプレート
ウェブ/コントローラ/ user_controller.ex
[...]
def show(conn, %{"id" => id}) do
user = Repo.get!(User, id) |> Repo.preload([:emails])
conn
|> assign(:user, user)
|> render("show.html")
end
[...]
ウェブ/テンプレート/ユーザー/ show.html.eex
[...]
<%= unless Enum.empty?(@user.emails) do %>
<%= render MyApp.EmailView, "index.html", emails: @user.emails %>
<% end %>
[...]
私はassign @conn not available in eex template.
エラーを取得しますそれと。どうすればこれを達成できますか?