Custom route for activeadmin actions?

前端 未结 3 842
情歌与酒
情歌与酒 2021-01-13 11:22

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

相关标签:
3条回答
  • 2021-01-13 11:45

    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
    
    0 讨论(0)
  • 2021-01-13 11:47

    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.

    0 讨论(0)
  • 2021-01-13 11:52

    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
    
    0 讨论(0)
提交回复
热议问题