Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

regard non_id_actions in do_load_resource like in do_authorize_resour… #73

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/canary/plugs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,20 @@ defmodule Canary.Plugs do
action = get_action(conn)
is_persisted = persisted?(opts)

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 [:new, :create] ->
action in create_actions ->
nil
true ->
fetch_resource(conn, opts)
Expand Down