Phoenix view render: Attaching multiple assigns

Here’s the scenario: Generate an art gallery page showing an artist’s work. Inside that view template, embed a voting form for a user to vote whether they like the artist.

Controller module to populate the artist page:
def show(conn, %{“id” => id}) do
application = Judging.get_application!(id)
changeset = Judging.change_vote(%Vote{})
render(conn, “show.html”, application: application, changeset: changeset)

Render tag for the form in the Show template:
<%= render “vote.html”, Map.put(assigns, :action, Routes.vote_path(@conn, :create)) %>

The problem I have here is that within the vote form, I need to populate gallery and artist IDs from the application data to send to the vote create function.

What’s the best way to get form.html to see that data? Does it need to be pushed into the changeset or is there a way I’ve not yet found to push it into the assigns?

Sorry for the newbie error, but in the embedded form, I was trying to render out rather than _@**application.id_. Issue solved.

1 Like