 
   def update(conn, defn, params) do
     model = defn.__struct__
-    resource_model = defn.resource_model |> base_name |> String.downcase |> String.to_atom
-    resource = conn.assigns.resource
+    resource = conn.assigns.resource
+    resource_name = resource_name(defn)
 
     changeset_fn = Keyword.get(defn.changesets, :update, &resource.__struct__.changeset/2)
-    changeset = ExAdmin.Repo.changeset(changeset_fn, resource, params[resource_model])
+    changeset = ExAdmin.Repo.changeset(changeset_fn, resource, params[resource_name])
+
     case ExAdmin.Repo.update(changeset) do
       {:error, changeset} ->
         conn = put_flash(conn, :inline_error, changeset.errors)

    model = defn.__struct__
    resource = conn.assigns.resource
    conn = Plug.Conn.assign(conn, :ea_required,
       model.__struct__.resource_model.changeset(resource).required)
    {conn, params, resource} = handle_after_filter(conn, :edit, defn, params, resource)
    contents = do_form_view(model, conn, resource, params)


  @moduledoc false
  use ExAdmin.Web, :controller
  require Logger
  import ExAdmin.Utils
  import ExAdmin.ParamsToAtoms
  require IEx
