   end
 
   def batch_action(conn, defn, %{batch_action: "destroy"} = params) do
-    model = defn.__struct__
-    resource_model = model.__struct__.resource_model
+    resource_model = defn.resource_model
 
     type = case ExAdmin.Schema.primary_key(resource_model) do
       nil -> :integer


  def show(conn, defn, params) do
    model = defn.__struct__

    resource = if Application.get_all_env(:auth_ex) != [] do
      resource_name = AuthEx.Utils.resource_name conn, model: defn.resource_model
      case conn.assigns[resource_name] do
        nil ->
          model.run_query(repo, defn, :show, params[:id])
        res ->
          res
      end
    else
      model.run_query(repo, defn, :show, params[:id])
    end

    if resource == nil do
      raise Phoenix.Router.NoRouteError, conn: conn, router: __MODULE__


  def create(conn, defn, params) do
    model = defn.__struct__
    resource = defn.resource_model.__struct__
    resource_model = defn.resource_model |> base_name |> String.downcase |> String.to_atom
    changeset_fn = Keyword.get(defn.changesets, :create, &resource.__struct__.changeset/2)
    changeset = ExAdmin.Repo.changeset(changeset_fn, resource, params[resource_model])

