 
   def update(conn, defn, params) do
     model = defn.__struct__
-    resource_model = model.__struct__.resource_model
-    |> base_name |> String.downcase |> String.to_atom
+    resource_model = defn.resource_model |> base_name |> String.downcase |> String.to_atom
     resource = model.run_query(repo, defn, :edit, params[:id])
 
     if resource == nil do


  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 new(conn, defn, params) do
    model = defn.__struct__
    resource = defn.resource_model.__struct__
    contents = do_form_view(model, conn, resource, params)

    render conn, "admin.html", html: contents, resource: resource, filters: nil, defn: defn
