1

I'm using ActiveAdmin with no default namespace (config.default_namespace = false). I have a User Resource without namespace as well as an User Resource in the :admin namespace. Both use custom update methods to achieve different behavior (users can change their own data, while admins can reset the password of any user).

This is the "default" user:

ActiveAdmin.register User do
  actions :show, :edit, :update
  menu false
  permit_params ...

  controller do
    def update
      # change account data
      ...
    end
  end

  form do |f|
    ...
  end
end

And this is the admin User:

ActiveAdmin.register User, namespace: :admin do
  actions :all
  menu
  permit_params ...

  controller do
    def create
      # invitation code
      ...
    end

    def update
      # password reset code
      ...
    end
  end

  index do
    ...
  end

  filter ...

  form partial: 'form'
end

Changing the user data works just fine, as well as inviting new users. The problem is the password reset. When submitting the corresponding form (route /admin/users/[id]/edit), the update of the non-namespaced users is called (same as when submitting /users/[id]/edit) instead of the update in my :admin namespace User resource.

Is this a bug or did I misconfigure something? I'm honestly stumped by this behavior, I don't even know how to proceed with debugging this.

Florian Koch
  • 1,372
  • 1
  • 30
  • 49

1 Answers1

0

The problem wasn't due to the namespaces, but because of my form... I'm using semantic_form_for, which automatically configures everything based on the model. Since it receives an User, the form action will always send the data to the default User route instead of the :admin route. Manually setting the url fixed the problem.

Florian Koch
  • 1,372
  • 1
  • 30
  • 49