Open philippneugebauer opened 7 years ago
I found the problematic function and line:
defp do_load_resource(conn, opts) do
...
loaded_resource =
cond do
is_persisted ->
fetch_resource(conn, opts)
action == :index ->
fetch_all(conn, opts)
action in [:new, :create] ->
nil
true ->
fetch_resource(conn, opts)
end
...
end
action in [:new, :create] ->
does not regard other non-id-actions while do_authorize_resource
does:
defp do_authorize_resource(conn, opts) do
...
non_id_actions =
if opts[:non_id_actions] do
Enum.concat([:index, :new, :create], opts[:non_id_actions])
else
[:index, :new, :create]
end
I refactored do_load_resource
a bit according to do_authorize_resource
resulting in the following and now it works:
create_actions =
if opts[:non_id_actions] do
Enum.concat([:new, :create], opts[:non_id_actions])
else
[:new, :create]
end
loaded_resource =
cond do
is_persisted ->
fetch_resource(conn, opts)
action == :index ->
fetch_all(conn, opts)
action in create_actions ->
nil
true ->
fetch_resource(conn, opts)
end
Let me know what you think about that and if it's fine, I will do a PR
When I want to access one of my custom routes, I get the following error
That's probably the interesting part of the call log:
I thought that was solved by
non_id_actions
but it does not help.