6

I'm making a page with activeadmin to update password of current user. I have a non-persisted model to check validation of password, etc. My problem is that when I try

ActiveAdmin.register UpdatePassword do
    actions :edit, :update
end

It creates the routes /update_passwords/:id and /update_passwords/:id/edit.

I want to change those routes to /update_passwords via get and put.

Is there any way to change that?

Bishma Stornelli
  • 2,539
  • 4
  • 22
  • 30

3 Answers3

12

I couldn't find a way to do it with activeadmin but defining the routes manually worked:

#config/routes.rb
match "/admin/update_passwords" => 'admin/update_passwords#edit', via: :get, as: "admin_update_passwords"
match "/admin/update_passwords" => 'admin/update_passwords#update', via: :post
Bishma Stornelli
  • 2,539
  • 4
  • 22
  • 30
4

Though the question is about 2 years old, but you can achieve routing as well as the customized method using collection_action or member_action. Refer this.

inquisitive
  • 3,738
  • 6
  • 30
  • 56
  • 1
    The doc doesn't said how to put constraint on the show page. let's say, normally that resource is viewed by id. Now, i want to be able to view by his email, so i need to put more constraint. How to do this? – Chamnap Aug 23 '15 at 07:30
0

It seems to me that the controller name UpdatePassword is confusing.

The paths end up being something like:

edit_admin_update_passwords_path
update_admin_update_passwords_path

I think that this would be better:

ActiveAdmin.register Password do
  actions :edit, :update
end

or

ActiveAdmin.register User do
  actions :edit, :update
end
rharriso
  • 1,151
  • 10
  • 11