This is almost perfect. For :index, :new or :create action the handle_not_found/2 will never call error handler. For our case it's essential to allow visit nested pages only if parent resource exists.
So now when I visit /hypervisors/999/networks the conn.assigns[:hypervisor will be nil, I'd expect a 404 error.
We have the
Network
model which belongs to theHypervisor
, and/networks
resources are nested like this:According to the docs
persisted
option is a bless for nested resources.This is almost perfect. For
:index
,:new
or:create
action thehandle_not_found/2
will never call error handler. For our case it's essential to allow visit nested pages only if parent resource exists.So now when I visit
/hypervisors/999/networks
theconn.assigns[:hypervisor
will benil
, I'd expect a 404 error.