Skip to content

Instantly share code, notes, and snippets.

@bryansray
Last active September 9, 2016 20:28
Show Gist options
  • Save bryansray/1197a7fdcb3d8c0127e1686e18d09841 to your computer and use it in GitHub Desktop.
Save bryansray/1197a7fdcb3d8c0127e1686e18d09841 to your computer and use it in GitHub Desktop.
Refactoring Episode Controller
def new(conn, %{"podcast_slug" => slug}, current_user) do
with podcast <- find_podcast_for_user(slug, current_user.id),
changeset <- build_episode(podcast) do
render(conn, :new, changeset: changeset, podcast: podcast)
else
_ -> redirect(conn, to: page_path(conn, :index))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment